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
(2)
2
(3)
3
4
(3)
5
(11)
6
(3)
7
(2)
8
(6)
9
(6)
10
(8)
11
(3)
12
(7)
13
(8)
14
(5)
15
(11)
16
(11)
17
(3)
18
(2)
19
(7)
20
(11)
21
(6)
22
(5)
23
(1)
24
25
26
(6)
27
(3)
28
(8)
29
(2)
30
(1)

Showing results of 144

<< < 1 .. 4 5 6 (Page 6 of 6)
From: Brad M. <bra...@gm...> - 2012年11月05日 22:38:59
>
>
>
> Essentially, you want a similar behavior to the markers in the scatter
> plots, right? As you zoom or resize the plot, the circle markers stay as
> circles and have the same size relative to the size of the figure. If that
> is what you want, the way to do that is very easy.
>
> ax1.scatter([0.5], [0.5], s=30)
>
> Or whatever size you want (units of points).
>
> I hope that helps!
> Ben Root
>
>
Hi Ben,
Thanks. I actually tried this before and it didn't appear to work for me.
But I think the problem was that I thought s was the radius in units of my
axes, and so was simply not seeing the dot on top of the line that was
already there. I was just choosing values that were way too small to see.
This should meet my needs.
I wonder if you would mind expanding on that sentence? Does the example I
> provide do what you want?
>
> Thanks,
> Phil
Phil, thanks for this example as well. It also would work for my purposes.
All I meant by that sentence is that, in my real script, I am plotting a
bunch of lines as well, and I just wanted these circles to also be present
in the plot (the example code I attached was simply the circles/ellipses).
Best,
Brad
From: Jason G. <jas...@cr...> - 2012年11月05日 22:23:33
On 11/5/12 3:50 PM, klo uo wrote:
> You can see there how to use Gimp and create mpl colormap and then later
> there is nifty code that will allow you to shift colormaps with a slider
Nice! I couldn't resist doing a Sage interact version of the slider thing:
http://aleph.sagemath.org/?q=89b0c945-2ce3-4645-bf61-dbe0eed2c5cd&lang=sage
Thanks,
Jason
--
Jason Grout
From: klo uo <kl...@gm...> - 2012年11月05日 21:50:39
I asked same question with different problem here:
http://matplotlib.1069221.n5.nabble.com/How-to-shift-colormap-td18451.html
You can see there how to use Gimp and create mpl colormap and then later
there is nifty code that will allow you to shift colormaps with a slider
>From your problem I assume you would want the first.
Here is ready made for you:
========================================
import matplotlib as mpl
import matplotlib.pyplot as plt
ccm = {
'red' : (
(0.000000, 0.000000, 0.000000),
(0.000001, 1.000000, 1.000000),
(0.500000, 0.500000, 0.500000),
(1.000000, 0.000000, 0.000000)
),
'green' : (
(0.000000, 0.000000, 0.000000),
(0.000001, 1.000000, 1.000000),
(0.500000, 0.500000, 0.500000),
(1.000000, 0.000000, 0.000000)
),
'blue' : (
(0.000000, 0.000000, 0.000000),
(0.000001, 1.000000, 1.000000),
(0.500000, 0.500000, 0.500000),
(1.000000, 0.000000, 0.000000)
)
}
cm = mpl.colors.LinearSegmentedColormap('my_map', ccm)
from numpy import outer, arange, ones
a = outer(arange(0, 1, 0.01), ones(10))
plt.imshow(a, cmap=cm)
plt.show()
========================================
From: Phil E. <pel...@gm...> - 2012年11月05日 21:26:55
Hi Brad,
I didn't quite follow what it was that you were trying to achieve, but the
following example may be of interest to you:
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse, Circle
import matplotlib.transforms as mtrans
fig = plt.figure()
ax1 = fig.add_subplot(111)
x_in_axes_coords, y_in_axes_coords = 0.5, 0.5
radius_in_axes = 0.3
coords = [[x_in_axes_coords, y_in_axes_coords],
 [x_in_axes_coords + radius_in_axes, y_in_axes_coords]]
coords = ax1.transAxes.transform(coords)
x_device, y_device = coords[0, :]
radius = coords[1, 0] - x_device
circle = Circle((x_device, y_device), radius,
 transform=mtrans.IdentityTransform())
fig.artists.append(circle)
plt.show()
Clearly, you will always have circles with this approach (the circle is
defined in device coordinates, i.e. pixels),
but with the way this is implemented, it does not behave in the same way as
axes coordinates do when you resize your window.
> I am trying to plot some small circles in my plotting window, in addition
to the curves I'm already plotting.
I wonder if you would mind expanding on that sentence? Does the example I
provide do what you want?
Thanks,
Phil
On 5 November 2012 20:51, Brad Malone <bra...@gm...> wrote:
> Hello,
>
> I am trying to plot some small circles in my plotting window, in addition
> to the curves I'm already plotting. If I don't want to set my x- and y-
> axis scales equal to each other, a naive drawing of a circle results in an
> ellipse. To fix this problem I found some nice example code online here :
> http://stackoverflow.com/questions/9230389/why-is-matplotlib-plotting-my-circles-as-ovals,
> which solves the problem by basically plotting an ellipse, but an ellipse
> which will look like a circle in the display window.
>
> That works all fine for me, but then, if I change my xlim or ylim using
> ax1.set_xlim((something1,something2)) then the solution no longer works,
> and I get an ellipse.
>
> A minimal example showing the breaking behavior can be seen below.
>
>
>
> import matplotlib.pyplot as plt
>> from matplotlib.patches import Ellipse, Circle
>>
>> fig = plt.figure()
>> ax1 = fig.add_subplot(111)
>> # uncomment the following line to see it break
>> #ax1.set_xlim((0.2,1))
>>
>> # calculate asymmetry of x and y axes:
>> x0, y0 = ax1.transAxes.transform((0, 0)) # lower left in pixels
>> x1, y1 = ax1.transAxes.transform((1, 1)) # upper right in pixes
>> dx = x1 - x0
>> dy = y1 - y0
>> maxd = max(dx, dy)
>> width = .15 * maxd / dx
>> height = .15 * maxd / dy
>> # a circle you expect to be a circle, but it is not
>> ax1.add_artist(Circle((.5, .5), .15))
>> # an ellipse you expect to be an ellipse, but it's a circle
>> ax1.add_artist(Ellipse((.75, .75), width, height))
>>
>> plt.show()
>
>
> I suppose the problem is that ax1.transAxes.transform commands return the
> same numbers, regardless of whether I've changed the limits or not. Is
> there an easy and clean way to fix this (perhaps a different command for
> getting x0,y0,x1, and y1)?
>
> Thanks for the help!
>
> Best,
> Brad
>
>
>
> ------------------------------------------------------------------------------
> LogMeIn Central: Instant, anywhere, Remote PC access and management.
> Stay in control, update software, and manage PCs from one command center
> Diagnose problems and improve visibility into emerging IT issues
> Automate, monitor and manage. Do more in less time with Central
> http://p.sf.net/sfu/logmein12331_d2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Benjamin R. <ben...@ou...> - 2012年11月05日 21:26:12
On Mon, Nov 5, 2012 at 4:22 PM, Jason Grout <jas...@cr...>wrote:
> On 11/5/12 3:19 PM, Benjamin Root wrote:
> >
> >
> > On Mon, Nov 5, 2012 at 3:51 PM, Brad Malone <bra...@gm...
> > <mailto:bra...@gm...>> wrote:
> >
> > Hello,
> >
> > I am trying to plot some small circles in my plotting window, in
> > addition to the curves I'm already plotting. If I don't want to set
> > my x- and y- axis scales equal to each other, a naive drawing of a
> > circle results in an ellipse. To fix this problem I found some nice
> > example code online here :
> >
> http://stackoverflow.com/questions/9230389/why-is-matplotlib-plotting-my-circles-as-ovals
> ,
> > which solves the problem by basically plotting an ellipse, but an
> > ellipse which will look like a circle in the display window.
> >
> > That works all fine for me, but then, if I change my xlim or ylim
> > using ax1.set_xlim((something1,something2)) then the solution no
> > longer works, and I get an ellipse.
> >
> > A minimal example showing the breaking behavior can be seen below.
> >
> >
> > I am probably gonna reply to that stackoverflow question with a better
> > response...
> >
> > Essentially, you want a similar behavior to the markers in the scatter
> > plots, right? As you zoom or resize the plot, the circle markers stay
> > as circles and have the same size relative to the size of the figure.
> > If that is what you want, the way to do that is very easy.
> >
> > ax1.scatter([0.5], [0.5], s=30)
> >
> > Or whatever size you want (units of points).
>
> I think the units are points^2, i.e., area of the circle...
>
> Thanks,
>
> Jason
>
>
Right, thank you. I keep forgetting that.
Ben Root
From: Jason G. <jas...@cr...> - 2012年11月05日 21:22:57
On 11/5/12 3:19 PM, Benjamin Root wrote:
>
>
> On Mon, Nov 5, 2012 at 3:51 PM, Brad Malone <bra...@gm...
> <mailto:bra...@gm...>> wrote:
>
> Hello,
>
> I am trying to plot some small circles in my plotting window, in
> addition to the curves I'm already plotting. If I don't want to set
> my x- and y- axis scales equal to each other, a naive drawing of a
> circle results in an ellipse. To fix this problem I found some nice
> example code online here :
> http://stackoverflow.com/questions/9230389/why-is-matplotlib-plotting-my-circles-as-ovals,
> which solves the problem by basically plotting an ellipse, but an
> ellipse which will look like a circle in the display window.
>
> That works all fine for me, but then, if I change my xlim or ylim
> using ax1.set_xlim((something1,something2)) then the solution no
> longer works, and I get an ellipse.
>
> A minimal example showing the breaking behavior can be seen below.
>
>
> I am probably gonna reply to that stackoverflow question with a better
> response...
>
> Essentially, you want a similar behavior to the markers in the scatter
> plots, right? As you zoom or resize the plot, the circle markers stay
> as circles and have the same size relative to the size of the figure.
> If that is what you want, the way to do that is very easy.
>
> ax1.scatter([0.5], [0.5], s=30)
>
> Or whatever size you want (units of points).
I think the units are points^2, i.e., area of the circle...
Thanks,
Jason
From: Benjamin R. <ben...@ou...> - 2012年11月05日 21:20:16
On Mon, Nov 5, 2012 at 3:51 PM, Brad Malone <bra...@gm...> wrote:
> Hello,
>
> I am trying to plot some small circles in my plotting window, in addition
> to the curves I'm already plotting. If I don't want to set my x- and y-
> axis scales equal to each other, a naive drawing of a circle results in an
> ellipse. To fix this problem I found some nice example code online here :
> http://stackoverflow.com/questions/9230389/why-is-matplotlib-plotting-my-circles-as-ovals,
> which solves the problem by basically plotting an ellipse, but an ellipse
> which will look like a circle in the display window.
>
> That works all fine for me, but then, if I change my xlim or ylim using
> ax1.set_xlim((something1,something2)) then the solution no longer works,
> and I get an ellipse.
>
> A minimal example showing the breaking behavior can be seen below.
>
I am probably gonna reply to that stackoverflow question with a better
response...
Essentially, you want a similar behavior to the markers in the scatter
plots, right? As you zoom or resize the plot, the circle markers stay as
circles and have the same size relative to the size of the figure. If that
is what you want, the way to do that is very easy.
ax1.scatter([0.5], [0.5], s=30)
Or whatever size you want (units of points).
I hope that helps!
Ben Root
From: Brad M. <bra...@gm...> - 2012年11月05日 20:51:32
Hello,
I am trying to plot some small circles in my plotting window, in addition
to the curves I'm already plotting. If I don't want to set my x- and y-
axis scales equal to each other, a naive drawing of a circle results in an
ellipse. To fix this problem I found some nice example code online here :
http://stackoverflow.com/questions/9230389/why-is-matplotlib-plotting-my-circles-as-ovals,
which solves the problem by basically plotting an ellipse, but an ellipse
which will look like a circle in the display window.
That works all fine for me, but then, if I change my xlim or ylim using
ax1.set_xlim((something1,something2)) then the solution no longer works,
and I get an ellipse.
A minimal example showing the breaking behavior can be seen below.
import matplotlib.pyplot as plt
> from matplotlib.patches import Ellipse, Circle
>
> fig = plt.figure()
> ax1 = fig.add_subplot(111)
> # uncomment the following line to see it break
> #ax1.set_xlim((0.2,1))
>
> # calculate asymmetry of x and y axes:
> x0, y0 = ax1.transAxes.transform((0, 0)) # lower left in pixels
> x1, y1 = ax1.transAxes.transform((1, 1)) # upper right in pixes
> dx = x1 - x0
> dy = y1 - y0
> maxd = max(dx, dy)
> width = .15 * maxd / dx
> height = .15 * maxd / dy
> # a circle you expect to be a circle, but it is not
> ax1.add_artist(Circle((.5, .5), .15))
> # an ellipse you expect to be an ellipse, but it's a circle
> ax1.add_artist(Ellipse((.75, .75), width, height))
>
> plt.show()
I suppose the problem is that ax1.transAxes.transform commands return the
same numbers, regardless of whether I've changed the limits or not. Is
there an easy and clean way to fix this (perhaps a different command for
getting x0,y0,x1, and y1)?
Thanks for the help!
Best,
Brad
From: Marian J. <mja...@ta...> - 2012年11月05日 20:35:00
Hi all, 
I am a newbie in matplotlib and I'd like to use colormap for z-axis. I
can use in basic mode but would like to shift the existed colormap -
binary - for using in this way: 
i would not like to set the white color for z=0.0 For describing: I
would like to use the binary colormap but without the white color
because this color I would like to leave for not-defined value for
(x,y). 
Is it possible to do this? Maybe create new colormap on the basis of
the "binary" but without the white color. 
Any suggestions? 
Thanks in advance for your help. 
best, 
Marian
From: Hans B. <han...@ar...> - 2012年11月05日 19:17:20
On 2012年11月02日 16:45:22 +0100, 
<mat...@li...> wrote:
> Message: 5
> Date: Fri, 2 Nov 2012 12:01:35 +0100
> From: Vlastimil Brom <vla...@gm...>
> Subject: Re: [Matplotlib-users] Figures piling up in Tkinter GUI
> 	(1.2.0rc2)
> To: mat...@li...
> Message-ID:
> 	<CAH...@ma...>
> Content-Type: text/plain; charset=ISO-8859-1
> 2012年11月1日 Hans Bering <han...@ar...>:
>> Hello everybody,
>>
>> I'm building a small Tkinter GUI using matplotlib, in which I have to
>> change/update plots quite often depending on user input (with different
>> contents & sizes, in different places in the GUI, etc.; but always only
>> one figure at a time).
>>
>> As a first resort, I regenerated the figures with plt.figure(...) 
>> whenever necessary; unfortunately, the program happily accumulated 
>> memory with
>> every new figure until the computer would no longer cooperate in a 
>> timely fashion. The following minimal script should demonstrate the 
>> tendency:
>>
> ...
>
> Hi,
> I'd recommend to use an embedded plot and only clear and replace its
> content [...]
> I only roughly adapted that source to use your function and the memory
> usage appears to be more effective (although there is some increase
> too - as displayed in Process Explorer). Would some variation of the
> following work for you?
[...]
Hi Vlastimil,
thanks for your effort; I had tried the approach of clearing & replacing 
the plot myself, too. Unfortunately, that approach has a different 
problem: Because of the figure's size, I have to present it with 
scrollbars, and clearing & reusing the plot does not seem to work when 
resizing & scrolling the plot. I had posted that problem as a question at 
Stackoverflow (as http://stackoverflow.com/questions/13197469 ), since I 
hoped it might be "easier"; i.e., just a misunderstanding on my part of 
how to wire together the scrollbars/canvas/figure. Please note that, while 
I also use plt.figure(...) in the post at Stackoverflow, the effect 
remains the same when using Figure(...) and ax.plot(...).
So basically I'm stuck between a rock and a hard place - I can either have 
the memory issue reported previously; or the plot won't behave properly 
with scrolling+resizing.
I am wondering: Should repeatedly creating Figures in a Tkinter GUI work, 
and could this be a Matplotlib bug worth mentioning on some bug tracker?
Thanks & Regards
Hans
From: Bob K. <rnk...@ya...> - 2012年11月05日 03:24:52
It looks like I have found a solution. I work for many hours on a problem
before posting so I am surprised I found this only one day after posting my
original question. I went digging in places I am not sure I should and came
with this command that appears to be a solution to my focus problem. It
would be nice to know from an expert if this the recommended method for
forcing focus in Matplotlib.
The command:
fig.canvas.get_tk_widget().focus_force()
My original demo code with the new command showing the focus behavior I
want:
import matplotlib.pyplot as plt
plt.ion()
fig = plt.figure(figsize=(10,8))
ax = fig.add_axes([.15,.1,.8,.65])
ax.plot([1,2,3])
ax.set_title('Fisrt Plot')
fig.canvas.get_tk_widget().focus_force()
raw_input('Enter to close and Continue: ')
#plt.close(fig)
fig2 = plt.figure(figsize=(10,8))
ax = fig2.add_axes([.15,.1,.8,.65])
ax.plot([1,2,3])
ax.set_title('Second Plot')
fig2.canvas.get_tk_widget().focus_force()
raw_input('Enter to close and Continue: ')
#plt.close(fig2)
fig.canvas.get_tk_widget().focus_force()
raw_input('Enter to close and Continue: ')
Bob Kestner
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Force-focus-on-Figure-tp39652p39654.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
In an Qt application I am extending, I display a list of thumbnails, 
selecting a thumbnail opens a plot window with the source of the 
thumbnail. I a newbie at all this but did manage to write a simple 
widget which embedded a matplotlib FigureCanvas. It appears that I also 
need to code the zoom to rectangle and save view functionality I like in 
the default plot window. I have no idea if this is easy or hard, so 
thought it may just be easier be able to reuse the default plotting 
window. When I show() a plot form within a Qt application I get the 
following message printed on the console:
QCoreApplication::exec: The event loop is already running
I think I understand the error, obviously the application I calling form 
control the even loop. I suppose I need to somehow supply a parent 
window to pylab plot or the show() function. Is there a way to create 
a plot and show so as not to use the main loop?
Thanks.
Brickle.
--
From: Bob K. <rnk...@ya...> - 2012年11月04日 04:55:10
Hello,
I have a package that has many functions that bring up plots to show data and interactive plots to interact with data. How can I have my figures show and both be on top and be in focus? The best way I have found to manage Matplotlib plots in my package is to use interactive mode plt.ion() and pause the program with raw_input() statements to show or interact with the plots. This has been working fine with one exception. I have not been able to figure out how have the plot figure come up and have the figure both be on top and in focus. I am using Window XP,Python 2.5.4, Matplotlib version 1.0.0 with backend Tkagg. Tk has a command focus_force(), I have not been able to find a similar command in Matplotlib. 
This is a simple example demonstrating the plotting behavior. The second plot is rendered but is not in windows focus. 
 
import matplotlib.pyplot as plt
plt.ion()
fig = plt.figure(figsize=(10,8))
ax = fig.add_axes([.15,.1,.8,.65])
ax.plot([1,2,3])
ax.set_title('Fisrt Plot')
raw_input('Enter to close and Continue: ')
plt.close(fig)
fig2 = plt.figure(figsize=(10,8))
ax = fig2.add_axes([.15,.1,.8,.65])
ax.plot([1,2,3])
ax.set_title('Second Plot')
raw_input('Enter to close and Continue: ')
plt.close(fig2)
 
 
Thank you,
 
Bob Kestner
From: Arek K. <ake...@ya...> - 2012年11月04日 01:25:27
Hi all,
I am aware when using overlapping axes twinx I can only pick the objects in the active axes.
I would like to pick objects (lines) in both axes.
Does anyone have the workaround to this problem
Regards,
Arek 
From: Benjamin R. <ben...@ou...> - 2012年11月02日 15:45:21
On Fri, Nov 2, 2012 at 3:18 AM, Alexandr <o.p...@gm...> wrote:
> Benjamin Root <ben.root@...> writes:
>
> >
> >
> > On Thu, Jun 9, 2011 at 10:13 AM, Benjamin Root <ben.root <at> ou.edu>
> wrote:
> >
> >
> >
> >
> > On Thu, Jun 9, 2011 at 6:25 AM, Richard Hofmeister <richard.hofmeister-
> 3jV...@pu...> wrote:
> > Hello mplot3d specialists,I would like to change the aspect ratio of the
> 3d
> axes similar to matlab's functionality with daspect() or the
> 'dataaspectratio'
> property of 3d-axes.In the end, the x-y-plane should be non-square due to
> different lengths (not range) of the x and y axis (i know that i can use
> the
> aspect property of the axes to set the x-z/y-z aspect ratio).There is also
> the
> package "scitools", which provides all the matlab-3d functions including
> daspect
> via a VTK-backend; that would be my next try.For the simple 3d-plotting
> without
> fancy shading, i would like to stick to mplot3d:
> >
> >
> >
> > Is it possible to change the axis lengths/aspect ratios
> independently?Richard
> >
> >
> >
> >
> > Richard,Good question. I have never thought about such a feature for
> mplot3d. Looking back at the code, it does not appear to be feasible to
> do in
> its current state, as the code seems to assume that the 3d grid is a
> constructed
> from a unit cube. However, I will see if I can add aspect multipliers to
> the
> point calculation and get arbitrary aspects. Maybe I can get that feature
> added
> into the upcoming 1.1.0 release.Ben Root
> >
> >
> >
> >
> > Richard,I took a look at how this might be implemented. There would
> have to
> be some extra work to make the plots look right when experiencing changes
> in
> aspect. I first tried an implementation of just the plot box aspect ratio
> (pbaspect) as a member variable of the axes object. It will probably turn
> into
> a property so that I can link it with a daspect value. Also, the values
> should
> be normalized to 1, unless you want to see some interesting
> shrinkage/growth of
> your plot area.Try my branch here:
> https://github.com/WeatherGod/matplotlib/tree/mplot3d/pbaspectAfterbuilding
> that branch, try the following script (shamelessly adapted from some
> Matlab help
> pages for pbaspect and daspect).import matplotlib.pyplot as pltfrom
> mpl_toolkits.mplot3d import Axes3Dimport numpy as npfig = plt.figure()ax =
> fig.gca(projection='3d')x, y = np.mgrid[-2:2:.2, -2:2:.2]z = x *
> np.exp(-x**2 -
> y**2)
> >
> > ax.plot_surface(x, y, z, rstride=1, cstride=1)ax.pbaspect = [1.0, 1.0,
> 0.25]plt.show()While this will squash the z-axis nicely, it does not force
> the
> z-ticks to be pruned, so it gets a little ugly. However, the axis ticks
> can be
> changed manually. Also, with some of my other changes coming soon, it
> should be
> possible for the Axes3D object to automatically adjust the spacing of the
> tick
> labels so that it is not impacted by the changes in aspect ratio in the
> perpendicular direction (i.e. - the x and y tick labels are closer to the
> axis
> due to the z-axis scaling).Keep an eye on that branch as I work to improve
> this
> feature, and feel free to contribute to it as well!Ben Root
> >
> >
> >
> ------------------------------------------------------------------------------
> > EditLive Enterprise is the world's most technically advanced content
> > authoring tool. Experience the power of Track Changes, Inline Image
> > Editing and ensure content is compliant with Accessibility Checking.
> > http://p.sf.net/sfu/ephox-dev2dev
> >
> > _______________________________________________
> > Matplotlib-users mailing list
> > Matplotlib-users@...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
>
>
> Hello!
>
> I am looking for a tool like pbaspect. The only question is how to
> implement it
> into matplotlib? Do you have a step by step instruction?
>
> Thank you.
> Regards,
> Alexandr
>
>
I guess there has been enough interest in this feature that I probably
should devote some time to correctly implementing it. I'll see what I can
do!
Ben Root
From: Vlastimil B. <vla...@gm...> - 2012年11月02日 11:01:43
2012年11月1日 Hans Bering <han...@ar...>:
> Hello everybody,
>
> I'm building a small Tkinter GUI using matplotlib, in which I have to
> change/update plots quite often depending on user input (with different
> contents & sizes, in different places in the GUI, etc.; but always only
> one figure at a time).
>
> As a first resort, I regenerated the figures with plt.figure(...) whenever
> necessary; unfortunately, the program happily accumulated memory with
> every new figure until the computer would no longer cooperate in a timely
> fashion. The following minimal script should demonstrate the tendency:
>
...
> Now I am wondering if I am missing some detail, e.g., some other clean-up
> procedure? Or should this work & could be a memory leak in matplotlib or
> Tkinter? And/or is this approach (of generating a new figure every time)
> not recommended in the first place? I tried reusing the figure, but some
> aspects like changing the layout in the GUI and applying new size and dpi
> then proved tricky in their own ways.
>
> Many thanks in advance,
> Hans
>
Hi,
I'd recommend to use an embedded plot and only clear and replace its
content (rather than tu use pyplot and recreate the figure multiple
times. I believe, changing of the figure should be possible too.
see e.g. the sample for tkinter
http://matplotlib.org/examples/user_interfaces/embedding_in_tk.html
I only roughly adapted that source to use your function and the memory
usage appears to be more effective (although there is some increase
too - as displayed in Process Explorer). Would some variation of the
following work for you?
hth,
 vbr
########################################
#!/usr/bin/env python
import matplotlib
matplotlib.use('TkAgg')
import math
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,
NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import Tkinter
root = Tkinter.Tk()
root.wm_title("Embedding in TK")
fig = Figure(figsize=(5,4), dpi=100)
ax = fig.add_subplot(111)
canvas = FigureCanvasTkAgg(fig, master=root)
canvas.show()
canvas.get_tk_widget().pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
toolbar = NavigationToolbar2TkAgg( canvas, root )
toolbar.update()
canvas._tkcanvas.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
plotShift = 0
def replot():
 global plotShift, a, f
 ax.clear()
 xVals = xrange(100)
 ax.plot(xVals, [math.sin(x + plotShift) for x in xVals])
 fig.canvas.draw()
 plotShift += 10
button = Tkinter.Button(master=root, text='replot', command=replot)
button.pack(side=Tkinter.BOTTOM)
Tkinter.mainloop()
From: Alexandr <o.p...@gm...> - 2012年11月02日 07:25:06
Benjamin Root <ben.root@...> writes:
> 
> 
> On Thu, Jun 9, 2011 at 10:13 AM, Benjamin Root <ben.root <at> ou.edu> wrote:
> 
> 
> 
> 
> On Thu, Jun 9, 2011 at 6:25 AM, Richard Hofmeister <richard.hofmeister-
3jV...@pu...> wrote:
> Hello mplot3d specialists,I would like to change the aspect ratio of the 3d 
axes similar to matlab's functionality with daspect() or the 'dataaspectratio' 
property of 3d-axes.In the end, the x-y-plane should be non-square due to 
different lengths (not range) of the x and y axis (i know that i can use the 
aspect property of the axes to set the x-z/y-z aspect ratio).There is also the 
package "scitools", which provides all the matlab-3d functions including daspect 
via a VTK-backend; that would be my next try.For the simple 3d-plotting without 
fancy shading, i would like to stick to mplot3d:
> 
> 
> 
> Is it possible to change the axis lengths/aspect ratios independently?Richard
> 
> 
> 
> 
> Richard,Good question. I have never thought about such a feature for 
mplot3d. Looking back at the code, it does not appear to be feasible to do in 
its current state, as the code seems to assume that the 3d grid is a constructed 
from a unit cube. However, I will see if I can add aspect multipliers to the 
point calculation and get arbitrary aspects. Maybe I can get that feature added 
into the upcoming 1.1.0 release.Ben Root
> 
> 
> 
> 
> Richard,I took a look at how this might be implemented. There would have to 
be some extra work to make the plots look right when experiencing changes in 
aspect. I first tried an implementation of just the plot box aspect ratio 
(pbaspect) as a member variable of the axes object. It will probably turn into 
a property so that I can link it with a daspect value. Also, the values should 
be normalized to 1, unless you want to see some interesting shrinkage/growth of 
your plot area.Try my branch here: 
https://github.com/WeatherGod/matplotlib/tree/mplot3d/pbaspectAfter building 
that branch, try the following script (shamelessly adapted from some Matlab help 
pages for pbaspect and daspect).import matplotlib.pyplot as pltfrom 
mpl_toolkits.mplot3d import Axes3Dimport numpy as npfig = plt.figure()ax = 
fig.gca(projection='3d')x, y = np.mgrid[-2:2:.2, -2:2:.2]z = x * np.exp(-x**2 - 
y**2)
> 
> ax.plot_surface(x, y, z, rstride=1, cstride=1)ax.pbaspect = [1.0, 1.0, 
0.25]plt.show()While this will squash the z-axis nicely, it does not force the 
z-ticks to be pruned, so it gets a little ugly. However, the axis ticks can be 
changed manually. Also, with some of my other changes coming soon, it should be 
possible for the Axes3D object to automatically adjust the spacing of the tick 
labels so that it is not impacted by the changes in aspect ratio in the 
perpendicular direction (i.e. - the x and y tick labels are closer to the axis 
due to the z-axis scaling).Keep an eye on that branch as I work to improve this 
feature, and feel free to contribute to it as well!Ben Root
> 
> 
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> 
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
Hello!
I am looking for a tool like pbaspect. The only question is how to implement it 
into matplotlib? Do you have a step by step instruction?
Thank you.
Regards,
Alexandr
From: Hans B. <han...@ar...> - 2012年11月01日 20:53:09
Hello everybody,
I'm building a small Tkinter GUI using matplotlib, in which I have to 
change/update plots quite often depending on user input (with different 
contents & sizes, in different places in the GUI, etc.; but always only 
one figure at a time).
As a first resort, I regenerated the figures with plt.figure(...) whenever 
necessary; unfortunately, the program happily accumulated memory with 
every new figure until the computer would no longer cooperate in a timely 
fashion. The following minimal script should demonstrate the tendency:
--- start of script ---
import math
 from Tkinter import Tk, Button
import Tkconstants
 from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
 from matplotlib.figure import Figure
 from matplotlib import pyplot as plt
def replot():
 global globalCanvas, globalFigure, plotShift
 # any variety of clean-up calls
 if globalFigure is not None:
 plt.close()
 globalCanvas.get_tk_widget().destroy()
 globalFigure.clf()
 globalFigure = Figure(dpi=120, figsize=(4, 4))
 globalCanvas = FigureCanvasTkAgg(globalFigure, master=root)
 globalCanvas.get_tk_widget().grid(row=0, column=1)
 xVals = xrange(100)
 ax = globalFigure.add_subplot(111)
 ax.plot(xVals, [math.sin(x + plotShift) for x in xVals])
 plotShift += 10
# MAIN
globalCanvas = None
globalFigure = None
plotShift = 0 # just to see the plot change
root = Tk()
draw_button = Button(root, text="Replot", command=replot)
draw_button.grid(row=0, column=0, sticky=Tkconstants.N)
root.mainloop()
--- end of script ---
I have tried various clean-up calls, but the effect (of memory piling up) 
is always the same. Using objgraph (http://mg.pov.lt/objgraph/), I took a 
look at object counts by adding the following snippet at the end of the 
"replot" call:
--- start of insertion ---
 import gc
 import objgraph
 gc.collect()
 print "---"
 for c in ('FigureCanvasTkAgg', 'Figure'):
 print "{}\t{}".format(len(objgraph.by_type(c)), c)
--- end of insertion ---
The output shows that the total number of both Figures and 
FigureCanvasTkAggs increases constantly (i.e., one each after the first 
call, then two each, etc.), whereas I had expected that old ones get 
released, and that the count remains at one each.
Now I am wondering if I am missing some detail, e.g., some other clean-up 
procedure? Or should this work & could be a memory leak in matplotlib or 
Tkinter? And/or is this approach (of generating a new figure every time) 
not recommended in the first place? I tried reusing the figure, but some 
aspects like changing the layout in the GUI and applying new size and dpi 
then proved tricky in their own ways.
Many thanks in advance,
Hans
Hello Daryl,
On Wed, Oct 31, 2012 at 9:48 PM, Daryl Herzmann <ak...@gm...> wrote:
> Howdy,
>
> I built basemap 1.0.5 and matplotlib 1.2.0rc3 via the simple command 'python
> setup.py bdist_rpm' without an error that I can tell. When I attempt to
> install them, I get a conflict between the two. For example:
>
> file /usr/lib64/python2.6/site-packages/mpl_toolkits/__init__.pyc from
> install of basemap-1.0.5-1.x86_64 conflicts with file from package
> matplotlib-1.2.0rc3-1.x86_64
> file /usr/lib64/python2.6/site-packages/mpl_toolkits/__init__.pyo from
> install of basemap-1.0.5-1.x86_64 conflicts with file from package
> matplotlib-1.2.0rc3-1.x86_64
>
> Working around this error is easy with some rpm flags, but was curious what
> the proper solution for this situation is?
In Debian we're dealing with this situation letting 'matplotlib'
package owning the "mpl_toolkits" namespace (so only matplotlib will
install the __init__.py file in that directory) and basemap will
install stuff in "mpl_toolkits/basemap" directory and depending on
matplotlib (it requires to NOT install mpl_toolkits/__init__.py file
when install basemap, by either remote it when creating the package or
similar solution).
This way matplotlib package will create the namespace for all the
other packages to install modules in it, and avoiding conflicts like
the one you described.
HTH,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi

Showing results of 144

<< < 1 .. 4 5 6 (Page 6 of 6)
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 によって変換されたページ (->オリジナル) /