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

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.

Showing 11 results of 11

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