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 3 results of 3

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

Showing 3 results of 3

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 によって変換されたページ (->オリジナル) /