Re: [Matplotlib-users] matplotlib CRASHes when saving as a postscript file

2010-01-08 Thread Jae-Joon Lee
I can reproduce this error with the current svn.

I doubt if this is a matplotlib issue, because it works fine if the
number of axes is small.
To me, it seems as some memory error in the ghostscript, but my quick
googling did not show any relevant information.
So, I hope some postscript expert take a look at the issue.

However, note that pcolormesh in backends other than agg is extremely
inefficient, and I strongly discourage its use in other backends.
Your current example could be much efficient if you simply can use
imshow. Do you have to use pcolormesh? Your current example seems to
be easily convertible to imshow, but you original example may not.

In case the use of pcolormesh is not avoidable, I can think of two workarounds.

1) save as pdf first then convert to eps. Saving as pdf will take as
much time as saving as ps.

2) Save as eps but rasterize the pcolormesh plots. This is my choice
and saving time is also not very long. As a matter of fact, whenever
pcolormesh is used, I strongly recommend to consider rasterizing it.

For your current script, you may add something like below at the end
of your for-loop.

  map1.set_zorder(0.5)
  map2.set_zorder(0.5)
  map3.set_zorder(0.5)
  ax1.set_rasterization_zorder(0.6)
  ax2.set_rasterization_zorder(0.6)
  ax3.set_rasterization_zorder(0.6)

This code needs to be inside the for-loop so that all the pcolormesh
plots get rasterized.
Also, note that, in your current script, the third pcolormesh plot is
assigned to "map2", instead of "map3", so you need to fix this first.

Regards,

-JJ


On Thu, Jan 7, 2010 at 11:17 AM, Eric Emsellem  wrote:
> Hi
>
> I finally managed to write a simplified version of my python script
> which crashes when trying to save the figure as a postscript file. (this
> is related to a previous post). See below. The script is provided, as
> well as the full error message.
>
> Sorry for the long script, but basically I am plotting 3x7 arrays via
> pcolormesh. The script looks pretty dum because it was adapted from a
> more complicated one where the bins/pixels are not exactly squared and
> are rotated. In the version below I have tried to remove the unncessary
> complication. And I get a failure from ghostscript when I try to save it
> as eps. It works when I save it as a png.
>
> Can anyone tell me what's wrong there? Again I am using:
>
> ### On an OpenSuse 11.2, 64b
> xpdf distiller (but I tried others).
> matplotlib 0.99.1.1
> backend WXAgg version 2.8.10.1
> Python 2.6.2 (r262:71600, Oct 24 2009, 03:15:21)
> IPython 0.10 -- An enhanced Interactive Python.
>
>
> THANKS
> Eric
> 
>
> ##
> # Script to run which crashes when saving the figure as an eps file
> ##
> #!/usr/bin/python
> import numpy as num
> import pylab as pl
>
> def  pos(i,j, w, h) :
>   return [0.05+ j*(w+0.02), 0.99 -  (i+1)*(h+0.023)+0.025, w, h]
>
>
> ## Opening the figure
> ## Figure
> pl.figure(1, figsize=(5*1.2, 7*1.5))
> fig = pl.gcf()
> pl.clf()
>
> ## Size of figure
> figH = fig.get_figheight()
> figW = fig.get_figwidth()
> w = 0.99 / 3. -0.03
> h =  0.99 / 7 - 0.022
>
> ## List of data to plot (I take 7 times the same stuff)
> listgal = ["1","2","3","4","5","6",",7"]
>
> ## Initialisation of start, end and step
> ngal = len(listgal)
> start = [-30.,-30.]
> end = [30.,30.]
> npix = [80,80]
> x = num.linspace(start[0],end[0], npix[0])
> y = num.linspace(start[1],end[1], npix[1])
> step = [x[1]-x[0], y[1]-y[0]]
> X,Y = num.meshgrid(x,y)
>
> ## Initialisation of data
> data = num.random.random((npix[0], npix[1]))
>
> pl.ioff()
> for k in range(ngal) :
>   gal = listgal[k]
>
>   ## Coordinates
>
>   ## Grid for rotation
>   Xp,Yp = X - step[0]/2., Y - step[1]/2.
>   X1,Y1 = X+step[0]/2.,Y+step[1]/2.
>   X2,Y2 = X-step[0]/2.,Y+step[1]/2.
>   X3,Y3 = X-step[0]/2.,Y-step[1]/2.
>   X4,Y4 = X+step[0]/2.,Y-step[1]/2.
>   minXc = num.min(num.concatenate((X1,X2,X3,X4)))
>   maxXc = num.max(num.concatenate((X1,X2,X3,X4)))
>   minYc = num.min(num.concatenate((Y1,Y2,Y3,Y4)))
>   maxYc = num.max(num.concatenate((Y1,Y2,Y3,Y4)))
>   dX = maxXc - minXc
>   dY = maxYc - minYc
>
>   ## Deriving the right aspect ratio etc
>   aspectIma = dX / dY
>   aspectFig = figW / figH
>   aspectWin = w / h
>   if (aspectIma < aspectWin*aspectFig) :
>      maxXc = maxXc * aspectFig * aspectWin / aspectIma
>      minXc = minXc * aspectFig * aspectWin / aspectIma
>   else :
>      maxYc = maxYc * aspectIma / (aspectFig * aspectWin)
>      minYc = minYc * aspectIma / (aspectFig * aspectWin)
>   extentR = minXc, maxXc, minYc, maxYc
>
>   cmap = pl.cm.jet
>   minI, maxI = 0., 1.
>   cmap.set_bad('w',1.0)
>   j = 0
>   ax1 = fig.add_axes(pos(k,j, w, h))
>   map1 = ax1.pcolormesh(Xp,Yp,data,shading='flat',vmin=minI,vmax=maxI,
> cmap=cmap)
>   pl.plot([0.],[0.],'k+', markersize=10, lw=3)
>   xticklabel

Re: [Matplotlib-users] dividing up subplots?

2010-01-08 Thread Jae-Joon Lee
On Sun, Jan 3, 2010 at 4:30 PM, per freem  wrote:
> is there a way to do this in matplotlib?

With subplots, I believe the answer is no. You may try to fiddle with
anchor positions of individual subplots, but this will only work for
some limited cases.

With axes_grid toolkit, yes.

-JJ

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Tkinter scripts

2010-01-08 Thread Alan G Isaac
On 1/8/2010 3:08 PM, David Arnold wrote:
> Does anyone have some Tkinter scripts using matplotlib they can share?


You may find the TSPlot and Histogram classes here
http://code.google.com/p/econpy/source/browse/trunk/abm/gridworld/gridworld.py
to be helpful.

fwiw,
Alan Isaac


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Tkinter scripts

2010-01-08 Thread David Arnold
All,

Does anyone have some Tkinter scripts using matplotlib they can share? I am 
just starting to learn Tkinter and I could use some examples.

David Arnold
College of the Redwoods
Department of Mathematics
--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] move annotation

2010-01-08 Thread Charles Roduit
Simply beautiful !

Thank's a lot, it's exactly what I wanted.

Le vendredi 08 janvier 2010 à 13:08 -0500, Jae-Joon Lee a écrit :
> this_annotation.xytext = (event.x, event.y)


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotib-users] missing legend-entry using twinx()

2010-01-08 Thread Jae-Joon Lee
This is because "legend" creates a legend only in the current axes.
Note that "twinx" creates a separate axes.

You need to manually specify which plot items to show in the legend.

http://matplotlib.sourceforge.net/users/legend_guide.html

Or, you may use axes_grid.parasite_axes which does this job for you
(but do not use this toolkit blindly but read the documentation)

http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes2.html

-JJ


On Thu, Jan 7, 2010 at 9:19 AM, Manuel Wittchen
 wrote:
> Hi,
>
> I'm plotting two y-axis with the twinx() command. But when I'm
> creating my legend there is only one entry in the legend-box instead
> of two.
> Here is my code:
>
> grafik1 = plt.figure()
>
> ax1 = grafik1.add_subplot(111)
> ax1.plot(TIME, BTM, color='red', label='Biomass')
> ax1.set_ylabel('Biomass')
>
> ax2 = ax1.twinx()
> ax2.plot(TIME, FLUOR, label='Productivity')
> ax2.set_ylabel('Produktivity')
> ax2.set_xlabel('Time')
>
> grafik1_legend = legend(loc=10)
>
> --
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Bug in demo_parasite_axes2 example?

2010-01-08 Thread Jae-Joon Lee
What version of matplotlib are you using?
This may be the bug that already have been fixed.
Neither with the maintenance branch nor the current svn reproduce this problem,
as can be easily seen from the gallery

http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes2.html

-JJ


On Thu, Jan 7, 2010 at 5:16 AM, Burly Cumberland  wrote:
> Hi,
>
> I've been playing around with the parasite_axes toolkit. It's very nice but
> I discovered from the example that I always get an extra set of x and y axis
> labels. See attached png. I've got around this by simply turning the first
> axis off. Is this a bug in the code or the example? Also there appears to be
> an additional set of axis label commands in the example.
>
> From demo_parasite_axes2.py
> --
>
> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> import matplotlib.pyplot as plt
>
> if 1:
>    fig = plt.figure(1)
>    plt.axis('off') # Extra line to remove unwanted axis labels
>    host = SubplotHost(fig, 111)
>
>    host.set_ylabel("Density")
>    host.set_xlabel("Distance")
>
>    par1 = host.twinx()
>    par2 = host.twinx()
>
>    par1.set_ylabel("Temperature")
>
>    par2.axis["right"].set_visible(False)
>
>    offset = 60, 0
>    new_axisline = par2.get_grid_helper().new_fixed_axis
>    par2.axis["right2"] = new_axisline(loc="right",
>                                       axes=par2,
>                                       offset=offset)
>
>    par2.axis["right2"].label.set_visible(True)
>    par2.axis["right2"].set_label("Velocity")
>
>    fig.add_axes(host)
>    plt.subplots_adjust(right=0.75)
>
>    host.set_xlim(0, 2)
>    host.set_ylim(0, 2)
>
>    host.set_xlabel("Distance") # Why reset these three labels..
>    host.set_ylabel("Density")
>    par1.set_ylabel("Temperature")
>
>    p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density")
>    p2, = par1.plot([0, 1, 2], [0, 3, 2], label="Temperature")
>    p3, = par2.plot([0, 1, 2], [50, 30, 15], label="Velocity")
>
>    par1.set_ylim(0, 4)
>    par2.set_ylim(1, 65)
>
>    host.legend()
>
>    host.axis["left"].label.set_color(p1.get_color())
>    par1.axis["right"].label.set_color(p2.get_color())
>    par2.axis["right2"].label.set_color(p3.get_color())
>
>    plt.draw()
>    plt.show()
>
> --
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Proper display of histograms with fixed bar widths

2010-01-08 Thread Jae-Joon Lee
On Wed, Jan 6, 2010 at 5:50 AM, Gergely Ungvary
 wrote:
> I guess I'm not
> the only one plotting statistical data with manually specified bins.

Yes, and mpl works fine with manually specified bins.
On the other hand, I don't see why you want to change the widths of
the bar. As far as I can see, that is not the correct representation
of the data.

Anyhow, here is a little example that makes your bars in equal width.
I never used "fixed width" bar so I'm not sure if this is what you
want.

-JJ


aa = np.random.rand(100)
bins = np.array([0., 0.2, 0.3, 0.8, 1.])
p = hist(aa, bins)

rects = p[2]
for r in rects:
r.set_width(0.1)

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] move annotation

2010-01-08 Thread Jae-Joon Lee
I think the current method names of Annotation class (originally from
the Text class) is a bit confusing.
And this needs to be fixed.
Anyhow, instead of calling set_position method, you need to set the
"xytext" attribute directly.

this_annotation.xytext = (event.x, event.y)

Regards,

-JJ


On Wed, Jan 6, 2010 at 9:49 AM,   wrote:
> Dear all,
>
> I have a little problem on understanding how to move an annotation on a
> plot.
>
> My idea is to make a plot where some informations follow the cursor when
> moving on the data, like you can see in plots from piwik (
> http://piwik.org/demo )
>
> In the script in attachment, I can follow the cursor coordinate, change the
> text of the annotation, but I cannot move it.
>
> I tried several things, but none worked.
>
> If you have any advices, I would be very happy.
>
> =
> Script : try_move_annotate.py
> =
> import numpy
> import matplotlib
> import matplotlib.pyplot as plt
>
> def on_motion(event):
> if event.inaxes:
> print "before setting position : "
> print this_annotation.get_position()
> this_annotation.set_text('coordinate : ' + str(event.x) + ' ' +
> str(event.y))
> this_annotation.set_position((event.x, event.y))
> print "after setting position : "
> print this_annotation.get_position()
> ax.draw_artist(this_annotation)
> plt.draw()
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
>
> ax.plot(range(10), range(10))
> this_annotation = ax.annotate("coordinate : ",
> xy = (100,100),
> xycoords = 'figure pixels',
> horizontalalignment = 'left',
> verticalalignment = 'top',
> fontsize = 20,
> fontweight = 'bold',# animated=True,
> bbox = dict(boxstyle="round", fc='black', ec="0.5", alpha=0.5)
> )
>
> fig.canvas.mpl_connect('motion_notify_event', on_motion)
> plt.show()
> ==
> END Script
> ==
> --
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] need plot advise

2010-01-08 Thread othererik

Mag,

Are you looking at time series or just a single value per user? 

Time series lends itself to a line plot. There are plenty of style options,
etc. to highlight each user and the average. 

If you're looking at a single value per user, a bar chart may be a good
choice:
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.bar
You could then show the average using a horizontal line? 
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.axhline


Mag Gam wrote:
> 
> I am new to matplot but I am liking it a lot. I am creating a webpage
> with Django and I would like to plot a user's usage and average usage.
> Therefore I am not sure what type of plot is the best type.
> 
> 

It sounds like you've already worked out using MPL in Django. I found the
following links useful if not:
http://bitsofpy.blogspot.com/2009/07/matplotlib-in-django.html
http://www.scipy.org/Cookbook/Matplotlib/Django
http://matplotlib.sourceforge.net/faq/howto_faq.html#matplotlib-with-django


I'm sure others have better ideas, just my 2c. 

-Erik Schweller
-- 
View this message in context: 
http://old.nabble.com/need-plot-advise-tp27075955p27078878.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Occlusion with

2010-01-08 Thread Sven Klomp
Hi,

I have problems using mpl_toolkits.mplot3d.Axes3D. I plotted two surfaces, one 
using plot_surface, the other using plot_wireframe. However, no occlusions are 
handled. One surface is always in front of the other. Sometimes, the surface 
hides the wireframe, sometimes the other way (see attachment). How can I 
achieve a real 3D plot of two surfaces?

Thanks for your help
Sven


plot.pdf
Description: Adobe PDF document
--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev ___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] need plot advise

2010-01-08 Thread Mag Gam
I am new to matplot but I am liking it a lot. I am creating a webpage
with Django and I would like to plot a user's usage and average usage.
Therefore I am not sure what type of plot is the best type.

The data looks like this:

user: 13.4
average: 17.5


It would also be nice if I can create a bell curve (normal
distribution) and show where the user fits into the curve.

TIA

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] bar/hist plots, bottom on top or right axis

2010-01-08 Thread Matthias Michler
Hi Renato,

I think you have to flip the x-axis of the left plot by for instance
ax1 = subplot(121, xlim=(1, 0))
and I think than hist(data, orientation='horizontal') or manually using 
barh-plots works fine.

Kind regards,
Matthias

On Thursday 07 January 2010 22:12:56 Renato Alves wrote:
> What I'm trying to accomplish is something like:
>
> http://bm2.genes.nig.ac.jp/RGM2/R_current/library/plotrix/man/images/big_py
>ramid.plot_001.png
>
> For that I was trying to use subplots where both draw in horizontal
> orientation but one will be flipped or mirrored.
>
> I couldn't find any parameter to do so. There is left for horizontal
> plots but no right. The same goes for bottom, but no top.
>
> Is there any way to achieve this?
>
> Thanks,
> Renato


--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users