SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(20)
2
(21)
3
(21)
4
(14)
5
(8)
6
(12)
7
(16)
8
(27)
9
(39)
10
(19)
11
(12)
12
(3)
13
(3)
14
(18)
15
(14)
16
(6)
17
(7)
18
(19)
19
(5)
20
(8)
21
(24)
22
(42)
23
(12)
24
(11)
25
(16)
26
(2)
27
(4)
28
(10)





Showing 19 results of 19

From: Gökhan S. <gok...@gm...> - 2011年02月10日 23:52:05
Hi,
I would simply try to attach the legend to the figure object instead of the
axis.
On Thu, Feb 10, 2011 at 4:20 PM, Jeff Layton <lay...@at...> wrote:
> Good evening,
>
> I've been trying to find a way to move the legend outside
> the plot so it doesn't cover it up. I've seen some things
> online but I can quite get them to work (probably just my
> lack of knowledge about matplotlib).
>
> The section of code creating the plot looks like,
>
> fig = plt.figure()
> ax = fig.add_subplot(1,1,1);
>
> p1 = ax.bar(ind, IO_Time_Plot, width, color="r", align='center');
> p2 = ax.bar(ind, Diff_Plot, width, color="y",
> bottom=IO_Time_Plot, align='center');
>
> ax.set_ylabel('Time (secs)');
> ax.set_title('Elapsed Time and IO Time',fontstyle='italic');
> ax.set_xticks(ind);
>
> group_labels = [];
> for item in names:
> group_labels.append(item);
>
> ax.set_xticklabels(group_labels);
>
> fig.autofmt_xdate();
>
> #ax.legend( bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.);
> ax.legend( (p1[0], p2[0]), ('IO Time', 'Total Elapsed Time'));
>
>
>
> You can see my attempt at moving the legend outside the bounding box
> but when I try this, the legend never appears.
>
> TIA!
>
> Jeff
>
>
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Gökhan
From: Jeff L. <lay...@at...> - 2011年02月10日 23:39:26
 I hate to be the first one to comment on this post but I forgot to give
the error message and version of matplotlib. The error is,
Traceback (most recent call last):
 File "./multi_file_test_2.py", line 460, in <module>
 ax.legend( (p1[0], p2[0]), ('IO Time', 'Total Elapsed Time'), 
bbox_to_anchor=(1.05, 1), loc=2);
 File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line 
3617, in legend
 self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'bbox_to_anchor'
The version of matplotlib I'm using is, 0.98.3-4ubuntu1
Jeff
> Good evening,
>
> I've been trying to find a way to move the legend outside
> the plot so it doesn't cover it up. I've seen some things
> online but I can quite get them to work (probably just my
> lack of knowledge about matplotlib).
>
> The section of code creating the plot looks like,
>
> fig = plt.figure()
> ax = fig.add_subplot(1,1,1);
>
> p1 = ax.bar(ind, IO_Time_Plot, width, color="r", align='center');
> p2 = ax.bar(ind, Diff_Plot, width, color="y",
> bottom=IO_Time_Plot, align='center');
>
> ax.set_ylabel('Time (secs)');
> ax.set_title('Elapsed Time and IO Time',fontstyle='italic');
> ax.set_xticks(ind);
>
> group_labels = [];
> for item in names:
> group_labels.append(item);
>
> ax.set_xticklabels(group_labels);
>
> fig.autofmt_xdate();
>
> #ax.legend( bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.);
> ax.legend( (p1[0], p2[0]), ('IO Time', 'Total Elapsed Time'));
>
>
>
> You can see my attempt at moving the legend outside the bounding box
> but when I try this, the legend never appears.
>
> TIA!
>
> Jeff
>
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jeff L. <lay...@at...> - 2011年02月10日 23:20:53
 Good evening,
I've been trying to find a way to move the legend outside
the plot so it doesn't cover it up. I've seen some things
online but I can quite get them to work (probably just my
lack of knowledge about matplotlib).
The section of code creating the plot looks like,
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1);
 p1 = ax.bar(ind, IO_Time_Plot, width, color="r", align='center');
 p2 = ax.bar(ind, Diff_Plot, width, color="y", 
bottom=IO_Time_Plot, align='center');
 ax.set_ylabel('Time (secs)');
 ax.set_title('Elapsed Time and IO Time',fontstyle='italic');
 ax.set_xticks(ind);
 group_labels = [];
 for item in names:
 group_labels.append(item);
 ax.set_xticklabels(group_labels);
 fig.autofmt_xdate();
 #ax.legend( bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.);
 ax.legend( (p1[0], p2[0]), ('IO Time', 'Total Elapsed Time'));
You can see my attempt at moving the legend outside the bounding box
but when I try this, the legend never appears.
TIA!
Jeff
From: Benjamin R. <ben...@ou...> - 2011年02月10日 22:40:36
On Thu, Feb 10, 2011 at 4:13 PM, Matthew Turk <mat...@gm...> wrote:
> Hi Ben,
>
> On Thu, Feb 10, 2011 at 5:06 PM, Benjamin Root <ben...@ou...> wrote:
> > On Thu, Feb 10, 2011 at 1:38 PM, Matthew Turk <mat...@gm...>
> wrote:
> >>
> >> Hi there,
> >>
> >> I'm plotting some images in latitude/longitude space. These are
> >> images generated using the HEALpix method for discretizing the sphere,
> >> but I have resampled them to a regular grid of phi, theta, and the
> >> resultant image is contained in a variable img. This is a fully-self
> >> contained snippet:
> >>
> >> import matplotlib.figure
> >> import matplotlib.backends.backend_agg
> >> import numpy
> >> from numpy import pi
> >>
> >> img = numpy.random.random((800, 800))
> >> fig = matplotlib.figure.Figure((10, 4.9))
> >> ax = fig.add_subplot(1,1,1,projection='mollweide')
> >> image = ax.imshow(img, extent=(-pi,pi,-pi/2,pi/2), clip_on=False,
> >> aspect=0.5)
> >> cb = fig.colorbar(image, orientation='horizontal')
> >> canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(fig)
> >> canvas.print_figure("hi.png")
> >>
> >> This makes a very nice looking figure, basically as expected: a black
> >> oval outline for the map projection with the image inside it, the
> >> lat/lon axes identified, etc. What I'm running into here is that I
> >> would like to fiddle with the size of the figure, to adjust the
> >> whitespace and the position of the colorbar and so on, but any
> >> adjustment to the height of the figure instantiation, for instance:
> >>
> >> fig = matplotlib.figure.Figure((10, 4.9))
> >>
> >> (and the rest unchanged) results in the black oval, the axes, but the
> >> image content is completely blank. Is this a bug, or just a subtlety
> >> I'm missing?
> >>
> >> Thanks for any ideas!
> >>
> >> Best,
> >>
> >> Matt
> >>
> >
> > I am curious, why are you saving the figure using canvas.print_figure()?
> > How is it different from fig.savefig()? If you, for some reason, must
> use
> > canvas.print_figure(), then it seems like you are creating a new canvas
> from
> > the figure (I don't know, maybe it grabs figure's existing canvas
> > object?). In other words, you could just simply do:
> >
> > fig.savefig("hi.png")
>
> Maybe I'm doing something wrong here, but in the example script I gave
> the figure does not have a canvas object affiliated with it; it's set
> to None until I execute this operation:
>
> canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(fig)
>
> At that point, fig.canvas is not None, and is the same canvas that I
> just created:
>
> >>> print fig.canvas
> None
> >>> canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(fig)
> >>> canvas.print_figure("hi.png")
> >>> fig.canvas
> <matplotlib.backends.backend_agg.FigureCanvasAgg instance at 0x10263d3b0>
> >>> canvas is fig.canvas
> True
>
> >
> > or, if you must use canvas.print_figure(), you could do:
> >
> > fig.canvas.print_figure()
> >
> > instead of the two lines you have right now.
> >
> > See if that makes a difference.
>
> Unfortunately it didn't end up making a difference. The image is
> still printed, with colorbar, with lat/lon lines, but no image in the
> center of the black oval for the projection.
>
> Thanks,
>
> Matt
>
>
I just figured out why you don't have a canvas object. It is because you
aren't creating your figure object correctly. Try this:
import matplotlib.pyplot as plt
import numpy
from numpy import pi
img = numpy.random.random((800, 800))
fig = plt.figure(figsize=(10, 4.9))
ax = fig.add_subplot(1,1,1,projection='mollweide')
image = ax.imshow(img, extent=(-pi,pi,-pi/2,pi/2), clip_on=False,
aspect=0.5)
cb = fig.colorbar(image, orientation='horizontal')
fig.savefig("hi.png")
Notice that the figure is created through the pyplot's figure() method.
Because pyplot knows the backend, it is able to assign the correct canvas
object when making the figure object. This can't be done from the Figure
constructor alone. Once a proper figure object is made, it can then
properly call savefig().
See if that helps!
Ben Root
From: Matthew T. <mat...@gm...> - 2011年02月10日 22:14:23
Hi Ben,
On Thu, Feb 10, 2011 at 5:06 PM, Benjamin Root <ben...@ou...> wrote:
> On Thu, Feb 10, 2011 at 1:38 PM, Matthew Turk <mat...@gm...> wrote:
>>
>> Hi there,
>>
>> I'm plotting some images in latitude/longitude space. These are
>> images generated using the HEALpix method for discretizing the sphere,
>> but I have resampled them to a regular grid of phi, theta, and the
>> resultant image is contained in a variable img. This is a fully-self
>> contained snippet:
>>
>> import matplotlib.figure
>> import matplotlib.backends.backend_agg
>> import numpy
>> from numpy import pi
>>
>> img = numpy.random.random((800, 800))
>> fig = matplotlib.figure.Figure((10, 4.9))
>> ax = fig.add_subplot(1,1,1,projection='mollweide')
>> image = ax.imshow(img, extent=(-pi,pi,-pi/2,pi/2), clip_on=False,
>> aspect=0.5)
>> cb = fig.colorbar(image, orientation='horizontal')
>> canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(fig)
>> canvas.print_figure("hi.png")
>>
>> This makes a very nice looking figure, basically as expected: a black
>> oval outline for the map projection with the image inside it, the
>> lat/lon axes identified, etc. What I'm running into here is that I
>> would like to fiddle with the size of the figure, to adjust the
>> whitespace and the position of the colorbar and so on, but any
>> adjustment to the height of the figure instantiation, for instance:
>>
>> fig = matplotlib.figure.Figure((10, 4.9))
>>
>> (and the rest unchanged) results in the black oval, the axes, but the
>> image content is completely blank. Is this a bug, or just a subtlety
>> I'm missing?
>>
>> Thanks for any ideas!
>>
>> Best,
>>
>> Matt
>>
>
> I am curious, why are you saving the figure using canvas.print_figure()?
> How is it different from fig.savefig()? If you, for some reason, must use
> canvas.print_figure(), then it seems like you are creating a new canvas from
> the figure (I don't know, maybe it grabs figure's existing canvas
> object?). In other words, you could just simply do:
>
> fig.savefig("hi.png")
Maybe I'm doing something wrong here, but in the example script I gave
the figure does not have a canvas object affiliated with it; it's set
to None until I execute this operation:
canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(fig)
At that point, fig.canvas is not None, and is the same canvas that I
just created:
>>> print fig.canvas
None
>>> canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(fig)
>>> canvas.print_figure("hi.png")
>>> fig.canvas
<matplotlib.backends.backend_agg.FigureCanvasAgg instance at 0x10263d3b0>
>>> canvas is fig.canvas
True
>
> or, if you must use canvas.print_figure(), you could do:
>
> fig.canvas.print_figure()
>
> instead of the two lines you have right now.
>
> See if that makes a difference.
Unfortunately it didn't end up making a difference. The image is
still printed, with colorbar, with lat/lon lines, but no image in the
center of the black oval for the projection.
Thanks,
Matt
>
> Ben Root
>
>
From: Benjamin R. <ben...@ou...> - 2011年02月10日 22:07:14
On Thu, Feb 10, 2011 at 1:38 PM, Matthew Turk <mat...@gm...> wrote:
> Hi there,
>
> I'm plotting some images in latitude/longitude space. These are
> images generated using the HEALpix method for discretizing the sphere,
> but I have resampled them to a regular grid of phi, theta, and the
> resultant image is contained in a variable img. This is a fully-self
> contained snippet:
>
> import matplotlib.figure
> import matplotlib.backends.backend_agg
> import numpy
> from numpy import pi
>
> img = numpy.random.random((800, 800))
> fig = matplotlib.figure.Figure((10, 4.9))
> ax = fig.add_subplot(1,1,1,projection='mollweide')
> image = ax.imshow(img, extent=(-pi,pi,-pi/2,pi/2), clip_on=False,
> aspect=0.5)
> cb = fig.colorbar(image, orientation='horizontal')
> canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(fig)
> canvas.print_figure("hi.png")
>
> This makes a very nice looking figure, basically as expected: a black
> oval outline for the map projection with the image inside it, the
> lat/lon axes identified, etc. What I'm running into here is that I
> would like to fiddle with the size of the figure, to adjust the
> whitespace and the position of the colorbar and so on, but any
> adjustment to the height of the figure instantiation, for instance:
>
> fig = matplotlib.figure.Figure((10, 4.9))
>
> (and the rest unchanged) results in the black oval, the axes, but the
> image content is completely blank. Is this a bug, or just a subtlety
> I'm missing?
>
> Thanks for any ideas!
>
> Best,
>
> Matt
>
>
I am curious, why are you saving the figure using canvas.print_figure()?
How is it different from fig.savefig()? If you, for some reason, must use
canvas.print_figure(), then it seems like you are creating a new canvas from
the figure (I don't know, maybe it grabs figure's existing canvas
object?). In other words, you could just simply do:
fig.savefig("hi.png")
or, if you must use canvas.print_figure(), you could do:
fig.canvas.print_figure()
instead of the two lines you have right now.
See if that makes a difference.
Ben Root
From: Matthew T. <mat...@gm...> - 2011年02月10日 19:39:05
Hi there,
I'm plotting some images in latitude/longitude space. These are
images generated using the HEALpix method for discretizing the sphere,
but I have resampled them to a regular grid of phi, theta, and the
resultant image is contained in a variable img. This is a fully-self
contained snippet:
import matplotlib.figure
import matplotlib.backends.backend_agg
import numpy
from numpy import pi
img = numpy.random.random((800, 800))
fig = matplotlib.figure.Figure((10, 4.9))
ax = fig.add_subplot(1,1,1,projection='mollweide')
image = ax.imshow(img, extent=(-pi,pi,-pi/2,pi/2), clip_on=False, aspect=0.5)
cb = fig.colorbar(image, orientation='horizontal')
canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(fig)
canvas.print_figure("hi.png")
This makes a very nice looking figure, basically as expected: a black
oval outline for the map projection with the image inside it, the
lat/lon axes identified, etc. What I'm running into here is that I
would like to fiddle with the size of the figure, to adjust the
whitespace and the position of the colorbar and so on, but any
adjustment to the height of the figure instantiation, for instance:
fig = matplotlib.figure.Figure((10, 4.9))
(and the rest unchanged) results in the black oval, the axes, but the
image content is completely blank. Is this a bug, or just a subtlety
I'm missing?
Thanks for any ideas!
Best,
Matt
Right now I use a customized FigureCanvasTkAgg and overwrite the draw() and
resize() methods to reset the z-order of the axes before drawing / resizing
the figure and to restore the desired z-order afterwards. This works quite
well but it would be nice to have the picking work like in version <=0.99.3.
----------------------- 
import matplotlib
matplotlib.use('TkAgg')
from numpy import arange, sin, pi, cos
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,
NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import Tkinter as Tk
root = Tk.Tk()
f = Figure(figsize=(5,4), dpi=100)
ax0 = f.add_subplot(111)
ax1 = ax0.twinx()
t = arange(0.0,3.0,0.01)
s1 = sin(2*pi*t)
s2 = 2*cos(2*pi*t)
ax0.plot(t,s1,color='red', picker=True)
ax1.plot(t,s2,picker=True)
ax0.my_zorder=0
ax1.my_zorder=0.1
class MyFigureCanvasTkAgg(FigureCanvasTkAgg):
 def draw(self):
 ax0 = self.figure.axes[0]
 ax1 = self.figure.axes[1]
 ax0.set_zorder(0)
 ax1.set_zorder(0)
 FigureCanvasTkAgg.draw(self)
 ax0.set_zorder(ax0.my_zorder)
 ax1.set_zorder(ax1.my_zorder)
 
 def resize(self, event):
 ax0 = self.figure.axes[0]
 ax1 = self.figure.axes[1]
 ax0.set_zorder(0)
 ax1.set_zorder(0)
 FigureCanvasTkAgg.resize(self, event)
 ax0.set_zorder(ax0.my_zorder)
 ax1.set_zorder(ax1.my_zorder)
def pick_cb(event):
 if event.artist.get_lw() > 1:
 event.artist.set_lw(1)
 else:
 event.artist.set_lw(3)
 f.canvas.draw()
 
def toggle():
 if ax0.my_zorder == 0:
 ax0.my_zorder=0.1
 ax1.my_zorder=0
 else:
 ax0.my_zorder=0
 ax1.my_zorder=0.1
 ax0.set_zorder(ax0.my_zorder)
 ax1.set_zorder(ax1.my_zorder)
canvas = MyFigureCanvasTkAgg(f, master=root)
canvas.show()
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
toolbar = NavigationToolbar2TkAgg(canvas, root)
toolbar.update()
canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
canvas.mpl_connect('pick_event', pick_cb)
button = Tk.Button(master=root, text='Toggle', command=toggle)
button.pack(side=Tk.BOTTOM)
Tk.mainloop() 
----------------------- 
-- 
View this message in context: http://old.nabble.com/onpick-on-a-2-y-plot-%28-via-twinx%28%29-%29-seems-to-only-allow-picking-of-second-axes%27s-artists-tp25049128p30893570.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Alejandro W. <ale...@gm...> - 2011年02月10日 14:20:48
On Wed, Feb 9, 2011 at 1:23 PM, Paul Ivanov <piv...@gm...> wrote:
> no need for interpolation - just use plt.step:
Thanks! Just what I need it.
Any reason for the step function not appearing in the main Matplotlib
page (http://matplotlib.sourceforge.net/)?
Alejandro.
From: Paul I. <piv...@gm...> - 2011年02月10日 10:54:29
Jorgos Castello, on 2011年02月10日 10:59, wrote:
> I installed Python 2.7.1 Mac OS X "32-bit" i386/PPC Installer
> (for Mac OS X 10.3 through 10.6 [2]) as you recommended and now
> it works fine. No errors anymore. THANKS !!!
>
> P.S. Thank you for MATPLOTLIB ;)
Jorgos,
Glad you got it sorted out, I'm forwarding your reply to the list
to confirm the error and workaround for anyone else who
encounters it in the future. 
Also forwarding so that your gratitude and enthusiasm get passed
on to everyone in the community - core developers, patch
submitters, actively engaged users, mailing list participants,
etc. Our collective involvement in whatever capacity is what
makes projects like matplotlib thrive!
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Paul I. <piv...@gm...> - 2011年02月10日 06:54:58
Jorgos Castello, on 2011年02月10日 02:52, wrote:
> First, my system is MacOS X SnowLeopard 10.6.6 / installed Python 2.7.1 ( not Apple Python ) / installed NumPy 1.5.1 / installed SciPy 0.9.0rc1/ installed matplotlib-1.0.1-python.org-32bit-py2.7-macosx10.3.dmg
> 
> Second, I tried to figure out that tutorial http://scipy.org/Cookbook/OptimizationDemo1 and after typing in "from pylab import *"
> I get following error:
> >>> from pylab import *
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_path.so: no matching architecture in universal wrapper
Hi Jorgos,
seems like you're using a 64 bit (or a multi-architecture)
version of python.
 import sys
 [bits for bits in 32,64 if sys.maxint+1 == 2**(bits-1)]
will tell you if you're using 32 or 64 bit mode. You'll have to
either force 32 bit mode, or install matplotlib from source (i
don't there are python2.7 64 bit version for OS X at this time)
more on how to do that in the comments of the top reply here:
http://stackoverflow.com/questions/3606964/no-matching-architecture-in-universal-wrapper-problem-in-wxpython
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Benjamin R. <ben...@ou...> - 2011年02月10日 02:13:51
On Wed, Feb 9, 2011 at 7:22 PM, Eric Firing <ef...@ha...> wrote:
> On 02/09/2011 02:29 PM, Benjamin Root wrote:
>
> >
> > Bug Report:
> >
> > At some point between the recent revision and r8934, setting the alpha
> > value to anythhing but None will cause the image to not show. I suspect
> > it has something to do with some of the recent revisions. Maybe the
> > alpha values were being converted into an integer, causing them to be
> > zero? Then again, even setting alpha to 1 will cause the image to
> > disappear.
> >
> > Ideas? Thoughts? I included an example script below.
>
> Fixed in 8968.
>
>
Thanks!
From: Jorgos C. <Jor...@gm...> - 2011年02月10日 01:52:57
Dear Reader,
I am a student at university and I was trying to install your Matplotlib library.
Well, I tried and failed ! Google&Co and your homepage couldn't help me anymore.
First, my system is MacOS X SnowLeopard 10.6.6 / installed Python 2.7.1 ( not Apple Python ) / installed NumPy 1.5.1 / installed SciPy 0.9.0rc1/ installed matplotlib-1.0.1-python.org-32bit-py2.7-macosx10.3.dmg
Second, I tried to figure out that tutorial http://scipy.org/Cookbook/OptimizationDemo1 and after typing in "from pylab import *"
I get following error:
>>> from pylab import *
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pylab.py", line 1, in <module>
 from matplotlib.pylab import *
 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pylab.py", line 220, in <module>
 from matplotlib import mpl # pulls in most modules
 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mpl.py", line 1, in <module>
 from matplotlib import artist
 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.py", line 6, in <module>
 from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/transforms.py", line 34, in <module>
 from matplotlib._path import affine_transform
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_path.so, 2): no suitable image found. Did find:
 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_path.so: no matching architecture in universal wrapper
>>>
I thought, that this error is because of downloading your MacOSX 10.3 version ( compiled with an older gcc compiler ... ) and so my system cannot use those files ?
So I wanted to know if you can update such a 10.6.6 dmg file to sourceforge if that is the solution for my problem. So many others could also download that with the same system like mine.
Would be great writing me back.
Yours Jorgos
-- 
Schon gehört? GMX hat einen genialen Phishing-Filter in die
Toolbar eingebaut! http://www.gmx.net/de/go/toolbar
From: Eric F. <ef...@ha...> - 2011年02月10日 01:22:50
On 02/09/2011 02:29 PM, Benjamin Root wrote:
>
> Bug Report:
>
> At some point between the recent revision and r8934, setting the alpha
> value to anythhing but None will cause the image to not show. I suspect
> it has something to do with some of the recent revisions. Maybe the
> alpha values were being converted into an integer, causing them to be
> zero? Then again, even setting alpha to 1 will cause the image to
> disappear.
>
> Ideas? Thoughts? I included an example script below.
Fixed in 8968.
From: Christoph G. <cg...@uc...> - 2011年02月10日 01:17:32
Attachments: colors_alpha_fix.diff
On 2/9/2011 4:29 PM, Benjamin Root wrote:
> On Wed, Feb 9, 2011 at 1:50 AM, Eric Firing <ef...@ha...
> <mailto:ef...@ha...>> wrote:
>
> On 02/08/2011 02:39 PM, Christoph Gohlke wrote:
> >
>
> >
> > Please consider the attached patch for the _image.frombyte
> function. It
> > avoids temporary copies in case of non-contiguous input arrays.
> Copying
> > a 1024x1024 slice out of a contiguous 4096x4096 RGBA or RGB array is
> > about 7x faster (a common case for zooming/panning). Copying
> contiguous
> > RGB input arrays is ~2x faster. Tested on win32-py2.7.
> >
> > Christoph
> >
>
> Thank you!
>
> Looks good, speeds up zooming and panning on large images as advertised.
> An 8000x8000 image is actually manageable now.
> interpolation='nearest' is still very slow until the image is
> substantially zoomed, but everything is quite quick with other
> interpolation styles. The slowness of 'nearest' looks like a basic
> characteristic of the implementation.
>
> I committed the patch in 8966.
>
> Before that I found and committed a big speed-up in Normalize.
>
> Eric
>
>
> Bug Report:
>
> At some point between the recent revision and r8934, setting the alpha
> value to anythhing but None will cause the image to not show. I suspect
> it has something to do with some of the recent revisions. Maybe the
> alpha values were being converted into an integer, causing them to be
> zero? Then again, even setting alpha to 1 will cause the image to
> disappear.
>
> Ideas? Thoughts? I included an example script below.
>
> Ben Root
>
>
> Example script:
>
>
> import numpy as np
> import matplotlib.pyplot as plt
>
> z = np.random.random((40, 50))
>
> fig = plt.figure()
> ax = fig.add_subplot(1, 2, 1)
> ax.imshow(z, alpha=1.0)
> ax.set_title('Blank!')
>
> ax = fig.add_subplot(1, 2, 2)
> ax.imshow(z, alpha=None)
> ax.set_title("Not Blank")
>
>
>
> plt.show()
>
>
>
This should fix it:
Index: lib/matplotlib/colors.py
===================================================================
--- lib/matplotlib/colors.py	(revision 8967)
+++ lib/matplotlib/colors.py	(working copy)
@@ -49,6 +49,7 @@
 'chartreuse' are supported.
 """
 import re
+import math
 import numpy as np
 from numpy import ma
 import matplotlib.cbook as cbook
@@ -547,6 +548,8 @@
 if alpha is not None:
 alpha = min(alpha, 1.0) # alpha must be between 0 and 1
 alpha = max(alpha, 0.0)
+ if bytes:
+ alpha = int(math.floor(alpha*255.9999999))
 if (lut[-1] == 0).all():
 lut[:-1, -1] = alpha
 # All zeros is taken as a flag for the default bad
Christoph
From: Eric F. <ef...@ha...> - 2011年02月10日 01:12:38
On 02/09/2011 02:29 PM, Benjamin Root wrote:
> On Wed, Feb 9, 2011 at 1:50 AM, Eric Firing <ef...@ha...
> <mailto:ef...@ha...>> wrote:
>
> On 02/08/2011 02:39 PM, Christoph Gohlke wrote:
> >
>
> >
> > Please consider the attached patch for the _image.frombyte
> function. It
> > avoids temporary copies in case of non-contiguous input arrays.
> Copying
> > a 1024x1024 slice out of a contiguous 4096x4096 RGBA or RGB array is
> > about 7x faster (a common case for zooming/panning). Copying
> contiguous
> > RGB input arrays is ~2x faster. Tested on win32-py2.7.
> >
> > Christoph
> >
>
> Thank you!
>
> Looks good, speeds up zooming and panning on large images as advertised.
> An 8000x8000 image is actually manageable now.
> interpolation='nearest' is still very slow until the image is
> substantially zoomed, but everything is quite quick with other
> interpolation styles. The slowness of 'nearest' looks like a basic
> characteristic of the implementation.
>
> I committed the patch in 8966.
>
> Before that I found and committed a big speed-up in Normalize.
>
> Eric
>
>
> Bug Report:
>
> At some point between the recent revision and r8934, setting the alpha
> value to anythhing but None will cause the image to not show. I suspect
> it has something to do with some of the recent revisions. Maybe the
> alpha values were being converted into an integer, causing them to be
> zero? Then again, even setting alpha to 1 will cause the image to
> disappear.
>
> Ideas? Thoughts? I included an example script below.
Thanks for the report. I'll fix it some time today.
Eric
>
> Ben Root
>
>
> Example script:
>
>
> import numpy as np
> import matplotlib.pyplot as plt
>
> z = np.random.random((40, 50))
>
> fig = plt.figure()
> ax = fig.add_subplot(1, 2, 1)
> ax.imshow(z, alpha=1.0)
> ax.set_title('Blank!')
>
> ax = fig.add_subplot(1, 2, 2)
> ax.imshow(z, alpha=None)
> ax.set_title("Not Blank")
>
>
>
> plt.show()
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Eric F. <ef...@ha...> - 2011年02月10日 01:06:14
On 02/09/2011 12:36 PM, Benjamin Root wrote:
> On Wed, Feb 9, 2011 at 1:50 AM, Eric Firing <ef...@ha...
> <mailto:ef...@ha...>> wrote:
>
> On 02/08/2011 02:39 PM, Christoph Gohlke wrote:
> >
>
> >
> > Please consider the attached patch for the _image.frombyte
> function. It
> > avoids temporary copies in case of non-contiguous input arrays.
> Copying
> > a 1024x1024 slice out of a contiguous 4096x4096 RGBA or RGB array is
> > about 7x faster (a common case for zooming/panning). Copying
> contiguous
> > RGB input arrays is ~2x faster. Tested on win32-py2.7.
> >
> > Christoph
> >
>
> Thank you!
>
> Looks good, speeds up zooming and panning on large images as advertised.
> An 8000x8000 image is actually manageable now.
> interpolation='nearest' is still very slow until the image is
> substantially zoomed, but everything is quite quick with other
> interpolation styles. The slowness of 'nearest' looks like a basic
> characteristic of the implementation.
>
> I committed the patch in 8966.
>
> Before that I found and committed a big speed-up in Normalize.
>
> Eric
>
>
> Eric,
>
> How much is the speed-up in Normalize? It might be worth it to apply it
> to LogNorm as well. (as an aside, I find the duplication of code in
> Normalize and friends a little disconcerting...).
Timing: I don't recall exactly, but it was along the lines of 3.5 
seconds getting knocked down to 0.6 seconds.
Yes, I will apply it to LogNorm.
Duplication: yes, but every time I look at it I see that there are 
subtle but essential differences here and there, so it does not look 
worthwhile to try to factor out the remaining commonality.
>
> Also, what would it take (if it is at all possible) to take advantage of
> these image optimizations while using pcolor?
The norm and cmap optimizations are already taken advantage of by all 
color mapping operations. The optimization of using uint8 was already 
being done in quadmesh, nonuniform image, and pcolor image (all used by 
pcolorfast). The image.frombyte optimization that Christoph just came 
up with (8966) is specific to image. There may be some similar 
optimizations that could be made for other image-like plots (reducing 
copying and temporaries), but I don't think there will be the same level 
of payoff. Pcolor itself is hopelessly slow by nature, and should be 
used only for relatively small arrays. And then there is hexbin, which 
is *really* slow. It could be sped up with the addition of some cython, 
but would need a quadmesh-like extension to make it really speedy. (All 
this is off the top of my head, so I may be misstating a point here and 
there.)
Eric
>
> Ben Root
>
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Robert A. <ab...@ss...> - 2011年02月10日 00:30:35
Tom,
I just went through this, though with version 1.01 of mpl, so it may be different. You can read the 
very long thread at:
http://www.mail-archive.com/mat...@li.../msg20031.html
Those who maintain mpl don't think there is a memory leak. What I found was that imshow() does 
consume a lot of memory (now fixed in the development version) and that the first 2 or so uses build 
on each other, but after that it levels off giving back memory after close(). There is a 
discrepancy between what python reports it's using and what the OS reports (I had 500MB from the OS, 
but only 150MB from python). There is a chance that ipython is caching your results (try ipython 
-pylab -cs 0), but when I ran without ipython, python still had a large portion of memory.
-robert
On 2/9/2011 3:52 PM, Tom Dimiduk wrote:
> I am using matplotlib pylab in association with ipython -pylab to show
> many large (~2000x2000 or larger) images. Each time I show another
> image it consumes more memory until eventually exhausting all system
> memory and making my whole system unresponsive.
>
> The easiest way to replicate this behaviour is with
> a = ones((3333,3333))
> imshow(a)
>
> optionally
>
> close()
>
> and then
>
> imshow(a)
>
> again. I am using ipython .10.1 and matplotlib 0.99.3. Is there
> something I should be doing differently to avoid this problem? Is it
> fixed in a later version?
>
> Thanks,
> Tom
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Benjamin R. <ben...@ou...> - 2011年02月10日 00:30:13
On Wed, Feb 9, 2011 at 1:50 AM, Eric Firing <ef...@ha...> wrote:
> On 02/08/2011 02:39 PM, Christoph Gohlke wrote:
> >
>
> >
> > Please consider the attached patch for the _image.frombyte function. It
> > avoids temporary copies in case of non-contiguous input arrays. Copying
> > a 1024x1024 slice out of a contiguous 4096x4096 RGBA or RGB array is
> > about 7x faster (a common case for zooming/panning). Copying contiguous
> > RGB input arrays is ~2x faster. Tested on win32-py2.7.
> >
> > Christoph
> >
>
> Thank you!
>
> Looks good, speeds up zooming and panning on large images as advertised.
> An 8000x8000 image is actually manageable now.
> interpolation='nearest' is still very slow until the image is
> substantially zoomed, but everything is quite quick with other
> interpolation styles. The slowness of 'nearest' looks like a basic
> characteristic of the implementation.
>
> I committed the patch in 8966.
>
> Before that I found and committed a big speed-up in Normalize.
>
> Eric
>
>
Bug Report:
At some point between the recent revision and r8934, setting the alpha value
to anythhing but None will cause the image to not show. I suspect it has
something to do with some of the recent revisions. Maybe the alpha values
were being converted into an integer, causing them to be zero? Then again,
even setting alpha to 1 will cause the image to disappear.
Ideas? Thoughts? I included an example script below.
Ben Root
Example script:
import numpy as np
import matplotlib.pyplot as plt
z = np.random.random((40, 50))
fig = plt.figure()
ax = fig.add_subplot(1, 2, 1)
ax.imshow(z, alpha=1.0)
ax.set_title('Blank!')
ax = fig.add_subplot(1, 2, 2)
ax.imshow(z, alpha=None)
ax.set_title("Not Blank")
plt.show()

Showing 19 results of 19

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /