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




Showing 13 results of 13

From: John H. <jd...@gm...> - 2009年03月26日 19:29:15
On Thu, Mar 26, 2009 at 10:00 AM, Tyler B <bo...@gm...> wrote:
> Hi there,
>
> Thanks for your help with my problem yesterday.. the code was fine,
> and it was a problem with my system. I installed a fresh copy of EPD's
> Python and that fixed it!
>
> I have a quick question about making the chart background transparent.
>
> Here's the original graph: http://screencast.com/t/YuRZLOnmg
>
> Here's what i looks like when I use 'fig.frameon= False' :
> http://screencast.com/t/ZFkUFRoor
> (the gray part is transparent)
>
> So how do I make the last remaining white part transparent? I still
> want to keep the black axis, and just get rid of the white.
>
Have you seen
http://matplotlib.sourceforge.net/faq/howto_faq.html?highlight=codex%20transparent#save-transparent-figures
You can make the axes transparent with
 ax.patch.set_alpha(0.5)
or turn off the axes face entirely with
 ac.patch.set_facecolor('None')
Note the string 'None' is not the symbol None -- the latter means "use the
default face color"
JDH
From: Sandro T. <mo...@de...> - 2009年03月26日 17:20:57
Hello,
I'm trying to describe how to plot polar graphs with mpl, but the doc
for the above functions (in pyplot api page) is a bit "reduced".
For example, thetagrids() doc says it receive a fmt karg but calling
with it the error:
AttributeError: Unknown property fmt
is returned.
I'd like to know if there's a better place to have doc about those
functions, or if
there's an effort to improve it already planned.
Cheers,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi
From: Tyler B <bo...@gm...> - 2009年03月26日 15:02:13
Hi there,
Thanks for your help with my problem yesterday.. the code was fine,
and it was a problem with my system. I installed a fresh copy of EPD's
Python and that fixed it!
I have a quick question about making the chart background transparent.
Here's the original graph: http://screencast.com/t/YuRZLOnmg
Here's what i looks like when I use 'fig.frameon= False' :
http://screencast.com/t/ZFkUFRoor
(the gray part is transparent)
So how do I make the last remaining white part transparent? I still
want to keep the black axis, and just get rid of the white.
Thanks!
Tyler
## Update the graph
r = mlab.csv2rec("gmail-count.txt", names='date,val1,val2',
 converterd={'date' : cbook.todatetime('%Y-%m-%d %H:%M:%S')})
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(r.date, r.val1, 'g-')
fig.autofmt_xdate ()
#fig.frameon= False
plt.savefig("gmail-graph.png")
From: Sandro T. <mo...@de...> - 2009年03月26日 15:00:21
Hi Jae-Joon,
thanks for the reply.
On Thu, Mar 26, 2009 at 02:51, Jae-Joon Lee <lee...@gm...> wrote:
> You need to adjust the keyword arguments, such as head_width, etc. The
But shouldn't the default arrow be a little bit "nicer" than it's now? :)
> arrow command itself is poorly documented and its keyword arguments
> are explained in
> matplitlib.patches.FancyArrow.
Ah, that's why even in pyploy.arrow() I could'nt find eny reference to
head_width & friends. In case I have some time to share on improve
arrow() docs, what docs should I look to? and changing
'doc/api/pyplot_api.rst' is the right place to achieve it?
> However, I recommend you to use
> annotate command instead of arrow (you can give empty string if you
> just need an arrow). For example,
>
> annotate("", (0.2, 0.2), (0.4, 0.4),
>        arrowprops=dict(arrowstyle="->"))
>
> more examples,
>
> http://matplotlib.sourceforge.net/examples/pylab_examples/annotation_demo.html
> http://matplotlib.sourceforge.net/examples/pylab_examples/annotation_demo2.html
I already treated annotation, but I would like to give the readers (of
the book) a much wider toolbox, so introducing bare arrows after
annotations seems straigthforward.
> Annotate does not adjust the xlim and ylim of your axes for you, thus
> it is your responsibility.
Yep, already noticed :D
Cheers,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi
From: C M <cmp...@gm...> - 2009年03月26日 05:19:03
Attachments: draggable_legend2.py
On Thu, Mar 26, 2009 at 12:19 AM, Jae-Joon Lee <lee...@gm...> wrote:
> Sorry, It's hard to track down what's wrong without actually running the code.
I really appreciate your patience.
> Change
>
> self.legend._loc = loc_in_norm_axes
>
> to
>
> self.legend._loc = tuple(loc_in_norm_axes)
>
> and see if it works.
>
That did it! Thank you.
> You need to call canvas.draw. However, it will draw whole figure
> again. If you're concerned about speed, you may consider to use blit
> method.
> http://matplotlib.sourceforge.net/examples/animation/animation_blit_wx.html
I'll look into it. For the time being, this is already a very good improvement.
Thanks so much for the help. For the archives, the working runnable
sample (if you have wxPython) is attached.
Che
From: Jae-Joon L. <lee...@gm...> - 2009年03月26日 04:19:07
Sorry, It's hard to track down what's wrong without actually running the code.
Change
 self.legend._loc = loc_in_norm_axes
to
 self.legend._loc = tuple(loc_in_norm_axes)
and see if it works.
You need to call canvas.draw. However, it will draw whole figure
again. If you're concerned about speed, you may consider to use blit
method.
http://matplotlib.sourceforge.net/examples/animation/animation_blit_wx.html
-JJ
On Wed, Mar 25, 2009 at 10:55 PM, C M <cmp...@gm...> wrote:
> On Wed, Mar 25, 2009 at 9:58 PM, Jae-Joon Lee <lee...@gm...> wrote:
>> Ah, my bad.
>>
>> Try
>>
>>  self.legend.parent.transAxes.inverted().transform_point(loc_in_canvas)
>>
>> legend.parent points to the parent axes.
>>
>> -JJ
>>
>
> That cleared up the error, thanks. But it is still not actually moving the
> legend. The coordinates are changing as you described it:
>
> loc position (JJ method) = [ 0.89354419 0.91002415]
> motion_event.x = 436
> motion_event.y = 349.0
> mouse moved x = 31
> mouse moved y = 3.0
> loc position (JJ method) = [ 0.90698505 0.91002415]
>
> but the legend doesn't move.
>
> I have tried to different ways of doing the draw method.
>
> 1. self.canvas.draw()
> That gives this error and does not move the legend:
> ValueError: The truth value of an array with more than one element is
> ambiguous. Use a.any() or a.all()
>
> 2. self.draw() (this is a method which draws the lines and legend
> originally in my class).
> That just does nothing, though the output is as shown above.
>
> What do I have to do to actually show the repositioned legend?
>
> Thanks for your patience,
> C
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: C M <cmp...@gm...> - 2009年03月26日 02:55:16
On Wed, Mar 25, 2009 at 9:58 PM, Jae-Joon Lee <lee...@gm...> wrote:
> Ah, my bad.
>
> Try
>
>  self.legend.parent.transAxes.inverted().transform_point(loc_in_canvas)
>
> legend.parent points to the parent axes.
>
> -JJ
>
That cleared up the error, thanks. But it is still not actually moving the
legend. The coordinates are changing as you described it:
loc position (JJ method) = [ 0.89354419 0.91002415]
motion_event.x = 436
motion_event.y = 349.0
mouse moved x = 31
mouse moved y = 3.0
loc position (JJ method) = [ 0.90698505 0.91002415]
but the legend doesn't move.
I have tried to different ways of doing the draw method.
1. self.canvas.draw()
That gives this error and does not move the legend:
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()
2. self.draw() (this is a method which draws the lines and legend
originally in my class).
That just does nothing, though the output is as shown above.
What do I have to do to actually show the repositioned legend?
Thanks for your patience,
C
From: Jae-Joon L. <lee...@gm...> - 2009年03月26日 01:58:40
Ah, my bad.
Try
 self.legend.parent.transAxes.inverted().transform_point(loc_in_canvas)
legend.parent points to the parent axes.
-JJ
On Wed, Mar 25, 2009 at 9:36 PM, C M <cmp...@gm...> wrote:
> On Wed, Mar 25, 2009 at 9:06 PM, Jae-Joon Lee <lee...@gm...> wrote:
>> As I said in my previous email, the _loc attribute of the legend need
>> to be in the normalized axes coordinate, i.e., the lower left corner
>> of the axes being (0,0) and the upper-right corner being (1,1). Thus,
>> it needs to be something like below.
>>
>> loc_in_canvas = self.legend_x + mouse_diff_x, self.legend_y + mouse_diff_y
>> loc_in_norm_axes =
>> self.legend.transAxes.inverted().transform_point(loc_in_canvas)
>> self.legend._loc = loc_in_norm_axes
>>
>> Note that it assumes that the parent of the legend is an Axes
>> instance, which I think is your case.
>> IHTH,
>>
>> -JJ
>
> Thanks, but I am getting this error now:
>
> AttributeError: 'Legend' object has no attribute 'transAxes'
>
> My legend is created this way:
>
> self.legend = self.subplot.legend(self.line_collections_list, ['1'],
> numpoints=1)
>
> And self.subplot is made this way:
>
> self.figure = Figure(None, dpi)
> self.subplot = self.figure.add_subplot(111)
>
> I thought self.subplot is an Axes instance. Is it not?
>
> Thank you,
> C
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2009年03月26日 01:51:51
You need to adjust the keyword arguments, such as head_width, etc. The
arrow command itself is poorly documented and its keyword arguments
are explained in
matplitlib.patches.FancyArrow. However, I recommend you to use
annotate command instead of arrow (you can give empty string if you
just need an arrow). For example,
annotate("", (0.2, 0.2), (0.4, 0.4),
 arrowprops=dict(arrowstyle="->"))
more examples,
http://matplotlib.sourceforge.net/examples/pylab_examples/annotation_demo.html
http://matplotlib.sourceforge.net/examples/pylab_examples/annotation_demo2.html
Annotate does not adjust the xlim and ylim of your axes for you, thus
it is your responsibility.
-JJ
On Wed, Mar 25, 2009 at 6:39 PM, Sandro Tosi <mo...@de...> wrote:
> Hello,
> I'm trying to use arrows but I'm a little stuck.
>
> In [1]: import matplotlib
>
> In [2]: matplotlib.__version__
> Out[2]: '0.98.5.3'
>
> First, simply
>
> import matplotlib.pyplot as plt
> plt.arrow(2,2,4,1)
>
> doesn't show anything, while at least a figure with an arrow in is
> expected (or it's by design?)
>
> Secondly, with this simple script:
>
> import matplotlib.pyplot as plt
> plt.plot(range(10))
> plt.arrow(2,2,4,1, linewidth=5)
> plt.arrow(3,3,1,4)
>
> the result is quite ugly :) Where is the arrow pointer (for example)?
>
> I hope I'm missing something, but even in examples like "usetex_demo"
> the arrows are drawn "by hand" :)
>
> Thanks,
> --
> Sandro Tosi (aka morph, morpheus, matrixhasu)
> My website: http://matrixhasu.altervista.org/
> Me at Debian: http://wiki.debian.org/SandroTosi
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: C M <cmp...@gm...> - 2009年03月26日 01:45:49
On Wed, Mar 25, 2009 at 9:06 PM, Jae-Joon Lee <lee...@gm...> wrote:
> As I said in my previous email, the _loc attribute of the legend need
> to be in the normalized axes coordinate, i.e., the lower left corner
> of the axes being (0,0) and the upper-right corner being (1,1). Thus,
> it needs to be something like below.
>
> loc_in_canvas = self.legend_x + mouse_diff_x, self.legend_y + mouse_diff_y
> loc_in_norm_axes =
> self.legend.transAxes.inverted().transform_point(loc_in_canvas)
> self.legend._loc = loc_in_norm_axes
>
> Note that it assumes that the parent of the legend is an Axes
> instance, which I think is your case.
> IHTH,
>
> -JJ
Thanks, but I am getting this error now:
AttributeError: 'Legend' object has no attribute 'transAxes'
My legend is created this way:
self.legend = self.subplot.legend(self.line_collections_list, ['1'],
numpoints=1)
And self.subplot is made this way:
self.figure = Figure(None, dpi)
self.subplot = self.figure.add_subplot(111)
I thought self.subplot is an Axes instance. Is it not?
Thank you,
C
From: Jae-Joon L. <lee...@gm...> - 2009年03月26日 01:24:01
Tony wrote a nice summary of the various coordinate system used in
MPL, but it seems that it didn't make into the official documentation
yet. Here is the link. This will give you some idea about the MPL's
coordinate system.
http://article.gmane.org/gmane.comp.python.matplotlib.general/14008
-JJ
On Wed, Mar 25, 2009 at 9:06 PM, Jae-Joon Lee <lee...@gm...> wrote:
> As I said in my previous email, the _loc attribute of the legend need
> to be in the normalized axes coordinate, i.e., the lower left corner
> of the axes being (0,0) and the upper-right corner being (1,1). Thus,
> it needs to be something like below.
>
> loc_in_canvas = self.legend_x + mouse_diff_x, self.legend_y + mouse_diff_y
> loc_in_norm_axes =
> self.legend.transAxes.inverted().transform_point(loc_in_canvas)
> self.legend._loc = loc_in_norm_axes
>
> Note that it assumes that the parent of the legend is an Axes
> instance, which I think is your case.
> IHTH,
>
> -JJ
>
>
> On Wed, Mar 25, 2009 at 8:26 PM, C M <cmp...@gm...> wrote:
>> Ok, getting there. When I print the various coordinates to stdout, it
>> SHOULD be working, but my legend is simply disappearing. This
>> is the stdout on one pixel move with the mouse in the x:
>>
>> mouse x position at pick time 489
>> mouse y position at pick time 349.0
>> Legend x position at pick time = 445.878125
>> Legend y position at pick time= 339.8
>> motion_event.x = 488
>> motion_event.y = 349.0
>> mouse moved x = 1
>> mouse moved y = 0.0
>> new legend location on move = (446.87812499999995, 339.80000000000001)
>> release
>>
>> But what instead happens is the legend poofs out of existence.
>>
>> At the end of the motion event, I am calling this:
>>
>> self.canvas.draw()
>> self.parent.Refresh()
>>
>> And wonder if I should be using some other way to redraw the legend?
>> Is it just not being redrawn this way? I thought I should use self.draw(),
>> which is a method in my class which draws the line and the legend,
>> but using that does nothing at all.
>>
>> Very stuck here. Any help appreciated.
>> C
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
From: Jae-Joon L. <lee...@gm...> - 2009年03月26日 01:06:30
As I said in my previous email, the _loc attribute of the legend need
to be in the normalized axes coordinate, i.e., the lower left corner
of the axes being (0,0) and the upper-right corner being (1,1). Thus,
it needs to be something like below.
 loc_in_canvas = self.legend_x + mouse_diff_x, self.legend_y + mouse_diff_y
 loc_in_norm_axes =
self.legend.transAxes.inverted().transform_point(loc_in_canvas)
 self.legend._loc = loc_in_norm_axes
Note that it assumes that the parent of the legend is an Axes
instance, which I think is your case.
IHTH,
-JJ
On Wed, Mar 25, 2009 at 8:26 PM, C M <cmp...@gm...> wrote:
> Ok, getting there. When I print the various coordinates to stdout, it
> SHOULD be working, but my legend is simply disappearing. This
> is the stdout on one pixel move with the mouse in the x:
>
> mouse x position at pick time 489
> mouse y position at pick time 349.0
> Legend x position at pick time = 445.878125
> Legend y position at pick time= 339.8
> motion_event.x = 488
> motion_event.y = 349.0
> mouse moved x = 1
> mouse moved y = 0.0
> new legend location on move = (446.87812499999995, 339.80000000000001)
> release
>
> But what instead happens is the legend poofs out of existence.
>
> At the end of the motion event, I am calling this:
>
> self.canvas.draw()
> self.parent.Refresh()
>
> And wonder if I should be using some other way to redraw the legend?
> Is it just not being redrawn this way? I thought I should use self.draw(),
> which is a method in my class which draws the line and the legend,
> but using that does nothing at all.
>
> Very stuck here. Any help appreciated.
> C
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: C M <cmp...@gm...> - 2009年03月26日 00:26:50
Ok, getting there. When I print the various coordinates to stdout, it
SHOULD be working, but my legend is simply disappearing. This
is the stdout on one pixel move with the mouse in the x:
mouse x position at pick time 489
mouse y position at pick time 349.0
Legend x position at pick time = 445.878125
Legend y position at pick time= 339.8
motion_event.x = 488
motion_event.y = 349.0
mouse moved x = 1
mouse moved y = 0.0
new legend location on move = (446.87812499999995, 339.80000000000001)
release
But what instead happens is the legend poofs out of existence.
At the end of the motion event, I am calling this:
self.canvas.draw()
self.parent.Refresh()
And wonder if I should be using some other way to redraw the legend?
Is it just not being redrawn this way? I thought I should use self.draw(),
which is a method in my class which draws the line and the legend,
but using that does nothing at all.
Very stuck here. Any help appreciated.
C

Showing 13 results of 13

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