[Matplotlib-users] Links in pdf

2009-11-28 Thread Fabricio Silva
Hi folks
I know it is possible to handle events in the figure canvas to interact
with plots and components of the figure, to even run shell commands,
etc...
I wish I could save include links in exported pdf file. Tell me whether
it is possible to have a pdf file containing matplotlib plots on which I
could click to run actions, in the same manner that pdf files can
include clickable URL...

More specifically, I have a figure with a bunch of nicely-formatted
subplots and I embed this figure in a beamer presentation. I wish I
could play the associated sound when I click on one of the subplots in
Beamer (running a shell command).

-- 
Fabrice Silva
Laboratory of Mechanics and Acoustics (CNRS, UPR 7051)


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] imagsc comparison

2009-11-28 Thread Brian Larsen
Hello all, 

several of my colleagues and I are 99% sure we are making the change from IDL 
to python-matplotlib.  I have just one issue that I am trying to work out that 
I need to solve.  We are so far really impressed and looking forward to the 
change.

I have seen discussion on this list about imagesc and imshow but none of them 
have quite answered the questions.  In IDL we spent way too much time writing 
an clone that is still not full featured:
http://people.bu.edu/balarsen/IDLdoc/imagesc.html

I have data of probability distributions which have an X and Y array associated 
with the axes of the 2-d distribution (image).  What I don't see how to do in 
any easy fashion is plot this data in a imshow() manner with the axes correct 
(which are unevenly distributed and need to be plotted on a log axes).  

This can be done with contourf(X,Y,Z) but this has a few issues:
- I dont see how to do a log axes on a contour
- contour is the wrong plot as the inherent smoothing that a contour does is 
highly undesirable.

Using matlab imagesc one can easily make plots similar to:
http://img269.yfrog.com/i/2dprob.png/
Imagine taking the above plot and make the pixels different sizes so that 
each pixel has identical counting statistics.  Now assume that one wanted the 
Y-axis to be plotted in log.

Anyone have any thoughts or toy examples?

Thanks much, 

Brian






-- 
---
Brian A Larsen
RBSP-ECT Instrument Suite Scientist

Boston University
Center for Space Physics
725 Commonwealth Ave, Rm 506
Boston, MA 02215-1401
T: 617-358-4945
F: 617-353-6463
balarsen --at -- bu.edu 




--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Links in pdf

2009-11-28 Thread Jouni K . Seppänen
Fabricio Silva si...@lma.cnrs-mrs.fr writes:

 I wish I could save include links in exported pdf file. Tell me whether
 it is possible to have a pdf file containing matplotlib plots on which I
 could click to run actions, in the same manner that pdf files can
 include clickable URL...

This is not possible with the current pdf backend. I imagine it would
not be too difficult to implement, but I am way too busy at work to do
it any time soon.

 More specifically, I have a figure with a bunch of nicely-formatted
 subplots and I embed this figure in a beamer presentation. I wish I
 could play the associated sound when I click on one of the subplots in
 Beamer (running a shell command).

Beamer comes with a package called multimedia, and I think it allows you
to achieve something much like this -- see the \sound and
\hyperlinksound macros. It might be difficult to make the hyperlink be
exactly some subplot, but perhaps you could use e.g. speaker icons as
link anchors and place them in suitable locations.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] axis on top for barh plot

2009-11-28 Thread Ernest Adrogué
28/11/09 @ 00:17 (+0100), thus spake Mike Anderson:
 Hi,
 
 How can I put the bottom axis on top (or on top AND on bottom) for a barh 
 plot?
 
 I'm trying to mimic this, made with gnuplot:
 
   http://www.hep.wisc.edu/cms/comp/cmsprod/dCacheUserUsage.png
 
 within matplotlib, and I've come close,
 
   http://www.hep.wisc.edu/cms/comp/cmsprod/diskUserUsage.png
 
 
 Also, is it possible to just have grid lines in one direction (say, 
 vertical), I don't think the horizontal grid is necessary.

It's somewhat counter-intuitive, but it can be done.
You have to create some twin axes with the twiny option,
then make the plot on the twin axes so it will use the
top axis. The bottom axis still have to be adjusted manually
to make it match the top one and remove the labels.

See this example:

import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

data = [21, 17, 18, 15, 14, 11, 9, 8, 4, 6, 7, 4, 5, 1, 3, 2, 0, 0]
names = ['%s%s' % (a, b)
 for a in 'abcdefg' for b in 'abcdefg'][:len(data)]

xlim = (0, max(data)+2)

fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax2 = ax1.twiny()

# actual plot
ax2.barh(range(len(data)), data[::-1], 1, align='center', color='red')

# x-axis
ax2.set_xlim(xlim)
ax1.set_xlim(xlim)
ax1.xaxis.set_major_formatter(ticker.NullFormatter())

# y-axis
ax2.set_ylim(-0.5, len(data)-1+0.5)
ax2.yaxis.set_major_locator(ticker.FixedLocator(range(len(data
ax2.yaxis.set_major_formatter(ticker.FixedFormatter(names[::-1]))

# grid
ax2.set_axisbelow(True)
ax1.set_axisbelow(True)
ax1.grid(True)

plt.show()


If you want only a vertical grid, use
ax1.xaxis.grid(True) instead of ax1.grid(True).

Bye.

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Links in pdf

2009-11-28 Thread Fabricio Silva
Le samedi 28 novembre 2009 à 17:04 +0200, Jouni K. Seppänen a écrit :
  More specifically, I have a figure with a bunch of nicely-formatted
  subplots and I embed this figure in a beamer presentation. I wish I
  could play the associated sound when I click on one of the subplots in
  Beamer (running a shell command).
 
 Beamer comes with a package called multimedia, and I think it allows you
 to achieve something much like this -- see the \sound and
 \hyperlinksound macros. It might be difficult to make the hyperlink be
 exactly some subplot, but perhaps you could use e.g. speaker icons as
 link anchors and place them in suitable locations.

I have the second solution by now. But I hope I will succeed to make a
clickable area match to each subplot, probably using tikz to set the
size of the area.


-- 
Fabrice Silva
Laboratory of Mechanics and Acoustics (CNRS, UPR 7051)


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [Newbie] question concerning color mapping

2009-11-28 Thread Pierre de Buyl
Hello,

the np.random.randn() functions returns a list (or an array if given  
appropriate arguments) of normal distributed numbers.

If x and y are also of length 100, each couple (x[i],y[i]) will be  
assigned a size size[i] and a color colours[i].

This happens not at all because of magic, but because the 's' and 'c'  
keyword arguments to scatter accept an array of number as the setting  
to give to each individual point.

The routine scatter automatically finds the maximun and minimum in  
colours and give to each point a color value according to the  
default colormap.

Details can be found in the docs:
http://matplotlib.sourceforge.net/api/ 
pyplot_api.html#matplotlib.pyplot.scatter

I could not find any newbie specific information on scatter.
If you need help regarding a function, it is available at the command  
line.

  help(scatter)

Pierre

Le 26 nov. 09 à 11:06, David a écrit :

 Dear list,

 I recently came across the following code:

 In [7]: size = 50*np.random.randn(100)
 In [8]: colours = np.random.rand(100)
 In [9]: scatter(x, y, s=size, c=colours);
 In [10]: show()

 which works beautifully. My question though is this: why?

 I came to understand, with Google's help, that the randomly generated
 values (ranging between 0.0 and 1.0) for the variable colours are  
 mapped
 to a color table, so that the generated value of, say, 0.21985792 is
 linked to a given color. This color is then used to paint one  
 scatter point.

 I was unable to find helpful (i.e. newbie friendly) information on how
 this color mapping exactly works. Where is the table? The matplotlib
 documentation caused me confusion.

 Thanks for your kind help,

 David



 -- 
 
 Let Crystal Reports handle the reporting - Free Crystal Reports  
 2008 30-Day
 trial. Simplify your report design, integration and deployment -  
 and focus on
 what you do best, core application coding. Discover what's new with
 Crystal Reports now.  http://p.sf.net/sfu/bobj-july
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] imagsc comparison

2009-11-28 Thread Eric Firing
Brian Larsen wrote:
 Hello all, 
 
 several of my colleagues and I are 99% sure we are making the change from IDL 
 to python-matplotlib.  I have just one issue that I am trying to work out 
 that I need to solve.  We are so far really impressed and looking forward to 
 the change.
 
 I have seen discussion on this list about imagesc and imshow but none of them 
 have quite answered the questions.  In IDL we spent way too much time writing 
 an clone that is still not full featured:
 http://people.bu.edu/balarsen/IDLdoc/imagesc.html
 
 I have data of probability distributions which have an X and Y array 
 associated with the axes of the 2-d distribution (image).  What I don't see 
 how to do in any easy fashion is plot this data in a imshow() manner with the 
 axes correct (which are unevenly distributed and need to be plotted on a log 
 axes).  
 
 This can be done with contourf(X,Y,Z) but this has a few issues:
 - I dont see how to do a log axes on a contour
 - contour is the wrong plot as the inherent smoothing that a contour does is 
 highly undesirable.
 
 Using matlab imagesc one can easily make plots similar to:
 http://img269.yfrog.com/i/2dprob.png/
 Imagine taking the above plot and make the pixels different sizes so that 
 each pixel has identical counting statistics.  Now assume that one wanted 
 the Y-axis to be plotted in log.
 
 Anyone have any thoughts or toy examples?

I am not sure I understand exactly what you want to do, but it sounds 
like pcolormesh would do it.  e.g. with ipython -pylab:

ax = gca()
ax.set_yscale('log')
x = np.arange(10)**1.5
y = np.arange(20)**1.8
z = x[1:] * y[1:, np.newaxis]
pcolormesh(x, y, z)
axis('tight')

Note that with x and y, which can be 1-D or 2-D, you are specifying the 
grid boundaries, not the pixel centers.

Eric



--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] showing xlabel and ylabel with 1eX notation

2009-11-28 Thread Pau
Hello,

I am doing a plot and the x axis shows a small 1e7 indicating that the
numbers should be multiplied by that quantity, but the y axis does not
and is showing labels like 0.07

Why is that? I would like it to also use the 1eX notation

Any comment will be appreciated

Thanks,

Pau

This is my script

#!/usr/bin/env python

from pylab import *

# Create arrays

H01 = load ('./h01_skipi.txt')
H99 = load ('./h99_skipi.txt')

# Define elements

t_01  = H01[:, 0] # 1st column
hplus_01  = H01[:, 1] # 2nd
hcross_01 = H01[:, 2] # 3rd

t_99  = H99[:, 0] # 1st column
hplus_99  = H99[:, 1] # 2nd
hcross_99 = H99[:, 2] # 3rd

# Create upper plot

subplot (211) # 2 rows 1 column 1st plot
grid(True)
# For settings see page 22 users_guide

ylabel (r'$h_+\,(r/M)$', size=18)

plot(t_01, hplus_01 , \
 linestyle='--', color='grey',
 linewidth=3)
plot(t_99, hplus_99 , \
 linestyle='-',color='red',
 linewidth=1)

# Create lower plot

subplot (212)
grid(True)

ylabel (r'$h_x\,(r/M)$', size=18)

plot(t_01, hcross_01 , \
 linestyle='--', color='grey',
 linewidth=3)
plot(t_99, hcross_99 , \
 linestyle='-', color='red',
 linewidth=1)

xlabel ('t (sec)', size=18) # At the end, so that it's common to all

# Draw the thing

show()

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Bug in matplotlib.patches' contains() method?

2009-11-28 Thread Jorge Scandaliaris
Hi,
I was trying to find out when a button_press_event happened inside a patch
(tried Circle and Rectangle) using the contains(mouseevent) method, but it
always seem to return True. I got the inspiration from the looking_glass.py
example, which also doesn't work as (Ithink) it should. I know Ican do this the
hard way, i.e. checking with event.xdata event.ydata, but I was really happy
there was already a pre-defined method for doing so.

Cheers,

Jorge


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] A Simple Example of histogram Using Range?

2009-11-28 Thread Wayne Watson
See Subject. I don't seem able to produce a simple example of using 
histogram that uses range. I tried a variety of ranges, range=(0,22), 
range=(0, 50.2), ... and I see no difference between any of the x values 
scale. Can someone provide an example that shows how it works?

-- 
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
  Obz Site:  39° 15' 7 N, 121° 2' 32 W, 2700 feet  

   350 350 350 350 350 350 350 350 350 350
 Make the number famous. See 350.org
The major event has passed, but keep the number alive.
 
Web Page: www.speckledwithstars.net/


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] question about explicit tick labels

2009-11-28 Thread Peter Williams
Hi All, 
I'm trying to create a set of strip charts so that I can see the relationships 
between a large number of time series.  I'd like to label the y-axis with a 
name on the left side and a value/percentile on the right hand side.  I can get 
the names on the left axis, and it looks very nice (yay Matplotlib!).  When I 
try to the code below I don't get the output I'd like.  None of the explicit 
tick labels that I'm setting make it to the display, and also the 3 charts on 
the page aren't kept separate (left tick labels from chart 132 hit the right 
tick labels from chart 131).  Any suggestions very appreciated. 

import numpy as np
import matplotlib.pyplot as plt

nameN = 25
obsN = 50

names = [foo%d % x for x in range(nameN)]
vols = np.random.uniform(0.2, 0.45, nameN)


labels = ['ValA', 'ValB', 'ValC']
d1 = np.random.normal(0,1, obsN*nameN).reshape(obsN, -1)*vols
d2 = np.random.normal(0,1, obsN*nameN).reshape(obsN, -1)*vols
d3 = np.random.normal(0,1, obsN*nameN).reshape(obsN, -1)*vols


f = 0.45
fig = plt.figure()
for label, dset, ax_id in zip(labels, (d1, d2, d3), (131, 132, 133)):

ax = fig.add_subplot(ax_id)

for i in range(len(names)):

mx = np.max(dset[:,i])
mn = np.min(dset[:,i])
y = i + dset[:,i]*2*f/(mx - mn) - f*(mx + mn)/(mx - mn) + 1
y_last = y[-1]*np.ones_like(y)
x = np.arange(obsN)
ax.fill_between(x, y_last, y)

ax.set_ylim((0, nameN + 1))
ax.set_yticks(range(1, nameN + 1))
ax.set_title(label, fontsize=10)

for tk, nm in zip(ax.yaxis.get_major_ticks(), list(reversed(names))):
tk.tick1On = False
tk.tick2On = False
tk.label1On = True
tk.label2On = True
tk.set_label1(nm)
tk.set_label2(%.1f\n(%.1f tile) % (36.2, 98.6))

#ytickNames = ax.set_yticklabels(list(reversed(names)), rotation = 45, 
fontsize = 8)


plt.show()

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Arrows between points in a plot?

2009-11-28 Thread Michael Cohen
Hi all,

I have a plot that has say 6 black X's, each separate, and 6 blue X's, 
also separate, denoting where x's 1-6 have moved to (from black to blue).
Currently each point is plotted with a separate plot function.
I would like to generate a plot where each black x and blue x pair has 
an arrow pointing from one to the other.

Currently I plot them like this:

x1black = value
y1black = value
plot([x1black],[y1black],'kx',markersize=10,markeredgewidth=2)
x1blue = value
y1blue = value
plot([x1blue],[y1blue],'bx',markersize=10,markeredgewidth=2)

If I plotted,
plot([x1black,x1blue],[y1black,y1blue])
I could make the line between them into an arrow, but I wouldn't be able 
to make one blue and the other black.

Also, I'd like to be able to curve my arrows to make them less confusing 
in case they intersect too much.


Can anyone point me to the right functions?

Cheers
Michael



--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users