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

Showing 19 results of 19

From: John L. <joh...@sb...> - 2011年09月17日 23:58:16
Hi, JJ,
Thanks for the reply.
On Sat, 2011年09月17日 at 23:04 +0900, Jae-Joon Lee wrote:
> Adding a patch to an axes does not mean it cannot be drawn outside of
> axes. As far as you set (or unset) proper clip box, artists can be
> drawn anywhere in the canvas regardless of the axes it belongs to.
> Here is an example,
>
> ax = subplot(111)
>
> from matplotlib.patches import FancyArrow
> p = FancyArrow(0.05, 0.5, 0.2, 0.0, width=0.01,
> length_includes_head=False,
> head_width=None, head_length=None,
> shape='full', overhang=0,
> head_starts_at_zero=False,
> transform=ax.figure.transFigure,
> clip_on=False)
> 
> ax.add_patch(p)
 
OK, clip boxes are new to me, I will read more. Your suggestion seems a
bit kludgy for a multi-panel plot like mine, but it looks like it might
get the job done.
> On Sat, Sep 17, 2011 at 6:10 AM, John Ladasky
> <joh...@sb...> wrote:
> > But that isn't my goal here. I want to add lines to the FIGURE,
outside
> > of any Axes. Does anyone know how to accomplish this? Thanks!
> 
> Not sure what you mean here.
I'm still fairly new to the Matplotlib code, but I have some experience
with wxPython and its sizers. Making objects work correctly when they
are resized often depends on choosing the right coordinate system for
scaling. 
In matplotlib, each Artist has its own coordinate space. It seemed most
logical that, for an object that is connected to the whole figure rather
than just one of its subplots, it should use the figure's coordinate
space. It appears that the "transform" keyword in your sample code
accomplishes that, though in a roundabout way.
Also, if I understand the structure of a Matplotlib.Artist object
correctly, each has a list of Artist children which gets called
recursively when one issues a draw command for the parent. Suppose
that, after defining my plot, I should delete the one subplot that
contains my FancyArrows, which happened to be drawn outside of that
subplot's normal clip box? The FancyArrows would be deleted along with
the subplot.
If defining the object hierarchy correctly is a sample matter of adding
an Artist object of the desired type into the object's list of children,
I would try this. Given that there are very specific methods like
Figure.text(), Figure.add_subplot(), etc., I suspected that it might be
more involved than that. These might just be convenience methods.
From: Klonuo U. <kl...@gm...> - 2011年09月17日 21:04:50
Yes, that seems the right way
I used it before but forgot it in the mean time
On Sat, Sep 17, 2011 at 10:56 PM, Benjamin Root <ben...@ou...> wrote:
> On Sat, Sep 17, 2011 at 3:51 PM, Klonuo Umom <kl...@gm...> wrote:
>>
>> I want to plot multiple plot lines, and would prefer lines to start at
>> x-axis beginning (so they "source" vertically from y-axis)
>> If I use suggested method from current replies lines would not start
>> from x-axis beginning, but I guess I'll need to look in Axes module
>> and make my preferences.
>> Thanks
>>
>
> Or you could set the x-axis limits...
>
> Ben Root
>
>
From: Benjamin R. <ben...@ou...> - 2011年09月17日 20:56:48
On Sat, Sep 17, 2011 at 3:51 PM, Klonuo Umom <kl...@gm...> wrote:
> I want to plot multiple plot lines, and would prefer lines to start at
> x-axis beginning (so they "source" vertically from y-axis)
> If I use suggested method from current replies lines would not start
> from x-axis beginning, but I guess I'll need to look in Axes module
> and make my preferences.
> Thanks
>
>
Or you could set the x-axis limits...
Ben Root
From: Klonuo U. <kl...@gm...> - 2011年09月17日 20:51:21
I want to plot multiple plot lines, and would prefer lines to start at
x-axis beginning (so they "source" vertically from y-axis)
If I use suggested method from current replies lines would not start
from x-axis beginning, but I guess I'll need to look in Axes module
and make my preferences.
Thanks
On Sat, Sep 17, 2011 at 10:42 PM, Benjamin Root <ben...@ou...> wrote:
>
> Sorry, I am used to working from the axes objects, not from the pyplot
> interface. Most of the axes methods are available to pyplot, but it looks
> like Axes.set_xticklabels() is not available to pyplot.
>
> But honestly, I think you are making this harder than it is. The line being
> drawn starts at (0, 0) coordinates. The plot is correct, and I am not sure
> what you are trying to acheive.
>
> Ben Root
>
>
From: Benjamin R. <ben...@ou...> - 2011年09月17日 20:43:04
On Sat, Sep 17, 2011 at 3:33 PM, Klonuo Umom <kl...@gm...> wrote:
> Hm.. it not within matplotlib.pyplot module... needs more digging
> OK, thanks
>
> On Sat, Sep 17, 2011 at 10:27 PM, Benjamin Root <ben...@ou...> wrote:
> >
> > On Sat, Sep 17, 2011 at 3:22 PM, Klonuo Umom <kl...@gm...> wrote:
> >>
> >> Thanks for your fast replies.
> >> One more thing if possible: How can I tell xticks() to start at 0 (at
> x-axis start)
> >
> > Maybe what you want is xtick_labels()? xticks() merely tells mpl where
> on the x-axis you want ticks to show up. xtick_labels() will tell mpl what
> to label each tick (but won't change how many there are and where they are
> placed).
> >
> > Ben Root
> >
>
Sorry, I am used to working from the axes objects, not from the pyplot
interface. Most of the axes methods are available to pyplot, but it looks
like Axes.set_xticklabels() is not available to pyplot.
But honestly, I think you are making this harder than it is. The line being
drawn starts at (0, 0) coordinates. The plot is correct, and I am not sure
what you are trying to acheive.
Ben Root
From: Klonuo U. <kl...@gm...> - 2011年09月17日 20:39:12
Yes, I noticed the same and indeed I used sorted values in original problem
I forgot to add it in my simplified snippet
On Sat, Sep 17, 2011 at 10:34 PM, John Hunter <jd...@gm...> wrote:
>
> While this is safe because calls to keys and values will return lists
> in congruent order of no intervening dict modifications are made
>
> http://stackoverflow.com/questions/835092/python-dictionary-are-keys-and-values-always-the-same-order
>
> it is a bit fragile because there is no guarantee the dict keys will
> be ordered, right, which is probably not what the OP wants. Maybe
>
> x = sorted(d.keys())
> y = [d[k] for k in x]
> plot(x, y)
>
From: John H. <jd...@gm...> - 2011年09月17日 20:34:56
On Sat, Sep 17, 2011 at 3:09 PM, Eric Firing <ef...@ha...> wrote:
> On 09/17/2011 09:57 AM, Klonuo Umom wrote:
>> Hi,
>> please consider this snippet:
>>
>> import matplotlib.pyplot as plt
>>
>> d={}
>> for i in range(1,21):
>>  d[i] = i**2
>>
>> plt.plot(d.values())
>
> This is plotting values against the zero-based index. What you want is
>
> plt.plot(d.keys(), d.values())
While this is safe because calls to keys and values will return lists
in congruent order of no intervening dict modifications are made
http://stackoverflow.com/questions/835092/python-dictionary-are-keys-and-values-always-the-same-order
it is a bit fragile because there is no guarantee the dict keys will
be ordered, right, which is probably not what the OP wants. Maybe
 x = sorted(d.keys())
 y = [d[k] for k in x]
 plot(x, y)
JDH
From: Klonuo U. <kl...@gm...> - 2011年09月17日 20:33:30
Hm.. it not within matplotlib.pyplot module... needs more digging
OK, thanks
On Sat, Sep 17, 2011 at 10:27 PM, Benjamin Root <ben...@ou...> wrote:
>
> On Sat, Sep 17, 2011 at 3:22 PM, Klonuo Umom <kl...@gm...> wrote:
>>
>> Thanks for your fast replies.
>> One more thing if possible: How can I tell xticks() to start at 0 (at x-axis start)
>
> Maybe what you want is xtick_labels()? xticks() merely tells mpl where on the x-axis you want ticks to show up. xtick_labels() will tell mpl what to label each tick (but won't change how many there are and where they are placed).
>
> Ben Root
>
From: Benjamin R. <ben...@ou...> - 2011年09月17日 20:28:22
On Sat, Sep 17, 2011 at 3:22 PM, Klonuo Umom <kl...@gm...> wrote:
> Thanks for your fast replies.
>
> One more thing if possible: How can I tell xticks() to start at 0 (at
> x-axis start)
>
Maybe what you want is xtick_labels()? xticks() merely tells mpl where on
the x-axis you want ticks to show up. xtick_labels() will tell mpl what to
label each tick (but won't change how many there are and where they are
placed).
Ben Root
From: Klonuo U. <kl...@gm...> - 2011年09月17日 20:23:50
Thanks for your fast replies.
One more thing if possible: How can I tell xticks() to start at 0 (at x-axis
start)
From: Benjamin R. <ben...@ou...> - 2011年09月17日 20:16:32
On Saturday, September 17, 2011, Klonuo Umom <kl...@gm...> wrote:
> Hi,
> please consider this snippet:
> import matplotlib.pyplot as plt
> d={}
> for i in range(1,21):
> d[i] = i**2
> plt.plot(d.values())
> plt.xticks(d.keys())
> plt.show()
>
> As it can be seen from attached screenshot, xticks values are shifted to
right (by 1).
> Seems strange, but perhaps something to do with Python 0-start.
> So why plot starts at beginning of x-axis and xticks start shifted by 1?
> How does regular matplotlib users handle similar code?
> Thanks
When you called plot() with only the y values, mpl will assume x values as
range(len(y)). Just call plot with both x and y values.
Ben Root
From: Eric F. <ef...@ha...> - 2011年09月17日 20:09:33
On 09/17/2011 09:57 AM, Klonuo Umom wrote:
> Hi,
> please consider this snippet:
>
> import matplotlib.pyplot as plt
>
> d={}
> for i in range(1,21):
> d[i] = i**2
>
> plt.plot(d.values())
This is plotting values against the zero-based index. What you want is
plt.plot(d.keys(), d.values())
> plt.xticks(d.keys())
> plt.show()
>
>
> As it can be seen from attached screenshot, xticks values are shifted to
> right (by 1).
>
> Seems strange, but perhaps something to do with Python 0-start.
> So why plot starts at beginning of x-axis and xticks start shifted by 1?
> How does regular matplotlib users handle similar code?
>
> Thanks
>
>
>
> ------------------------------------------------------------------------------
> BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> http://p.sf.net/sfu/rim-devcon-copy2
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Nicolas R. <Nic...@in...> - 2011年09月17日 17:23:01
Hi folks,
I am pleased to announce a new release of glumpy, a small python library for the (very) fast vizualization of numpy arrays, (mainly two dimensional) that has been designed with efficiency in mind. If you want to draw nice figures for inclusion in a scientific article, you’d better use matplotlib but if you want to have a sense of what’s going on in your simulation while it is running, then maybe glumpy can help you.
Download and screenshots at: http://code.google.com/p/glumpy/
Nicolas
From: Kurt M. <kur...@su...> - 2011年09月17日 16:50:38
Am 17.09.2011 um 15:38 schrieb Jae-Joon Lee:
> Thanks for reporting this.
> I opened a pull request that I believe fixes this problem.
> https://github.com/matplotlib/matplotlib/pull/472
Thank you very much!
> Please test this if you can.
I hope next week.
> Depending on your need, you may work around this by calling all the
> set_position method always after all the GridSpec.update call.
Thanks, yes this will work for me.
-- 
kur...@gm...
From: Jae-Joon L. <lee...@gm...> - 2011年09月17日 14:04:35
On Sat, Sep 17, 2011 at 6:10 AM, John Ladasky
<joh...@sb...> wrote:
> But that isn't my goal here. I want to add lines to the FIGURE, outside
> of any Axes. Does anyone know how to accomplish this? Thanks!
Not sure what you mean here.
Adding a patch to an axes does not mean it cannot be drawn outside of
axes. As far as you set (or unset) proper clip box, artists can be
drawn anywhere in the canvas regardless of the axes it belongs to.
Here is an example,
Regards,
-JJ
ax = subplot(111)
from matplotlib.patches import FancyArrow
p = FancyArrow(0.05, 0.5, 0.2, 0.0, width=0.01,
 length_includes_head=False,
 head_width=None, head_length=None,
 shape='full', overhang=0,
 head_starts_at_zero=False,
 transform=ax.figure.transFigure,
 clip_on=False)
ax.add_patch(p)
From: Jae-Joon L. <lee...@gm...> - 2011年09月17日 13:53:05
Thanks for reporting this.
This is now fixed in the v1.0.x-maint branch and the master branch.
Regards,
-JJ
On Sat, Sep 17, 2011 at 10:33 AM, Daniel Hyams <dh...@gm...> wrote:
> In http://matplotlib.sourceforge.net/users/annotations_guide.html ,
> about 1/3 of the way down, there is a little demonstrator for the
> different arrowstyles ->, <-, ]-, etc.
>
> Looking at the figure closely, there is no difference between the "-["
> and "]-" styles.
>
> The fix for this is in patches.py, around line 3276 (matplotlib
> 1.0.0). Comments in that routine clipped out for brevity.
>
>  class BracketA(_Bracket):
>    def __init__(self, widthA=1., lengthA=0.2, angleA=None):
>
>      super(ArrowStyle.BracketA, self).__init__(None,True,
>           widthA=widthA, lengthA=lengthA, angleA=angleA )
>
> If you flip the first two args of the __init__ call, that fixes it:
>
>  class BracketA(_Bracket):
>    def __init__(self, widthA=1., lengthA=0.2, angleA=None):
>
>      super(ArrowStyle.BracketA, self).__init__(True,None,
> ############## flip these arguments
>           widthA=widthA, lengthA=lengthA, angleA=angleA )
>
>
> --
> Daniel Hyams
> dh...@gm...
>
> ------------------------------------------------------------------------------
> BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> http://p.sf.net/sfu/rim-devcon-copy2
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2011年09月17日 13:39:14
Thanks for reporting this.
I opened a pull request that I believe fixes this problem.
https://github.com/matplotlib/matplotlib/pull/472
Please test this if you can.
Depending on your need, you may work around this by calling all the
set_position method always after all the GridSpec.update call.
Regards,
-JJ
On Sat, Sep 17, 2011 at 1:37 AM, Kurt Mueller
<kur...@gm...> wrote:
> Hi,
>
>
> In the following script, it seems to me,
> that GridSpec does not work as expected.
> ----------------------------------------
> #!/usr/bin/env python
> # vim: set fileencoding=utf-8 :
> # adapted from http://matplotlib.sourceforge.net/users/gridspec.html
>
> import matplotlib.pyplot as plt
> from matplotlib.gridspec import GridSpec
>
> fig = plt.figure()
>
> gs1 = GridSpec(3,3)
> gs1.update( left=0.10, right=0.45 )
> ax1 = fig.add_subplot( gs1[ 0:1, 0:1 ] )
> ax1.set_position( [0.1, 0.1, 0.2, 0.8] )
>
> gs2 = GridSpec(3,3)
> gs2.update( left=0.55, right=0.95 )
> ax2 = fig.add_subplot( gs2[ 1:3, 1:3 ] )
> ax2.set_position( [0.5, 0.1, 0.2, 0.8] )
>
> plt.show()
> ----------------------------------------
>
> First I put an Axes ax1 with gs1.
> For some reason, I want to adjust ax1 with ax1.set_position.
> (In the real application only fine adjust)
> If I run the script only to this point it works as expected.
>
> Next I put another Axes ax2 with a new GridSpec gs2.
> With the command gs2.update() the Axes ax1 will be put back
> to the place where it would be without ax1.set_position().
>
> Is this behavior to be explained?
>
>
>
> Thanks
> --
> Kurt Mueller
>
> ------------------------------------------------------------------------------
> BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> http://p.sf.net/sfu/rim-devcon-copy2
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2011年09月17日 13:01:51
On Thu, Sep 15, 2011 at 10:33 PM, Jonathan Slavin
<js...@cf...> wrote:
> I'm wondering if there is some way to do cross hatching as a way to fill
> contours rather than colors (using contourf). The only references to
> cross hatching I see in the documentation are for patches type objects.
> As far as I can tell, contour and contourf return objects of their own
> type (contour.QuadContourSet) that do not have hatch as an attribute.
>
Yes, it seems that hatching is only supported in patches.
You may workaround this by converting contours to multiple patches.
See the attachment.
> If it's not possible currently, how hard would it be to add that
> capability to contourf? What approach would you recommend?
>
It may not be that difficult, but seems to require an api change
(e.g., draw_path_collections).
Can you file an issue on our github page?
Regards,
-JJ
> Regards,
> Jon
>
>
> ------------------------------------------------------------------------------
> Doing More with Less: The Next Generation Virtual Desktop
> What are the key obstacles that have prevented many mid-market businesses
> from deploying virtual desktops?  How do next-generation virtual desktops
> provide companies an easier-to-deploy, easier-to-manage and more affordable
> virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Daniel H. <dh...@gm...> - 2011年09月17日 01:40:21
In http://matplotlib.sourceforge.net/users/annotations_guide.html ,
about 1/3 of the way down, there is a little demonstrator for the
different arrowstyles ->, <-, ]-, etc.
Looking at the figure closely, there is no difference between the "-["
and "]-" styles.
The fix for this is in patches.py, around line 3276 (matplotlib
1.0.0). Comments in that routine clipped out for brevity.
 class BracketA(_Bracket):
 def __init__(self, widthA=1., lengthA=0.2, angleA=None):
 super(ArrowStyle.BracketA, self).__init__(None,True,
 widthA=widthA, lengthA=lengthA, angleA=angleA )
If you flip the first two args of the __init__ call, that fixes it:
 class BracketA(_Bracket):
 def __init__(self, widthA=1., lengthA=0.2, angleA=None):
 super(ArrowStyle.BracketA, self).__init__(True,None,
############## flip these arguments
 widthA=widthA, lengthA=lengthA, angleA=angleA )
-- 
Daniel Hyams
dh...@gm...
1 message has been excluded from this view by a project administrator.

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