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



Showing 14 results of 14

From: Benjamin R. <ben...@ou...> - 2012年02月02日 22:02:00
On Thu, Feb 2, 2012 at 3:52 PM, Jerzy Karczmarczuk <
jer...@un...> wrote:
> Benjamin Root :
> > Just about any mpl plotting function (plot(), scatter(), hist(), etc.)
> > returns an object. Most of the time, users do not save the result
> > into a variable, but if you want to do advanced tricks, you will need
> > to save those returns.
> Sorry for a shameless attempt to add something to this, but actually
> here you don't need it, these collections are accessible through the
> current axes:
>
>
> plt.plot([0, 1, 2, 3, 4], [4, 3, 2, 1, 0])
> pts = plt.scatter([1, 2, 3], [1, 2, 3])
>
> ax=plt.gca()
> ...
> del ax.collections[:]
>
>
I forget if this approach is recommended or not. There are methods for ax
that properly handle removal of types of artists that have been attached to
an axes. The above approach assumes that no other collections have been
plotted that you wanted to keep. The approach I gave is a very surgical
method that makes sure that only what is supposed to be removed gets
removed. Both are valid, and their usefulness depends upon which view of
the data you need (remove types of artists versus removing particular
artists).
> This reminds me a nuisance... Under Windows XP, ion() is not too
> compatible with show().
> TKAgg (by default), WXAgg and GTKAgg bomb Bens program (and without
> draw() nothing is plotted).
>
>
That would be a bug and should be reported (assuming that it is in the
latest version). Make sure that you are using at least v1.0.1 (preferably
v1.1.0) to make sure that show() should do what you want. Any version
earlier than v1.0.1 is very unpredictable with respect to multiple show()
calls.
Ben Root
From: Jerzy K. <jer...@un...> - 2012年02月02日 21:52:24
Benjamin Root :
> Just about any mpl plotting function (plot(), scatter(), hist(), etc.) 
> returns an object. Most of the time, users do not save the result 
> into a variable, but if you want to do advanced tricks, you will need 
> to save those returns.
Sorry for a shameless attempt to add something to this, but actually 
here you don't need it, these collections are accessible through the 
current axes:
plt.plot([0, 1, 2, 3, 4], [4, 3, 2, 1, 0])
pts = plt.scatter([1, 2, 3], [1, 2, 3])
ax=plt.gca()
...
del ax.collections[:]
(Or, say, del ax.lines[:] to remove the first line ; I do it often when 
I plot a solution of a differential equation, a trajectory, keeping just 
a few last segments).
==
This reminds me a nuisance... Under Windows XP, ion() is not too 
compatible with show().
TKAgg (by default), WXAgg and GTKAgg bomb Bens program (and without 
draw() nothing is plotted).
Jerzy Karczmarczuk
From: Benjamin R. <ben...@ou...> - 2012年02月02日 21:09:49
On Thu, Feb 2, 2012 at 3:04 PM, G Jones <gle...@gm...> wrote:
> Note there is a typo. Ben assigned the output to "pts" but then referenced
> "res".
>
>
Good catch!
Ben Root
From: G J. <gle...@gm...> - 2012年02月02日 21:04:36
Note there is a typo. Ben assigned the output to "pts" but then referenced
"res".
On Thu, Feb 2, 2012 at 12:59 PM, Benjamin Root <ben...@ou...> wrote:
> On Thu, Feb 2, 2012 at 2:54 PM, Jim St.Cyr <jim...@gm...> wrote:
>
>> On 2/2/2012 3:41 PM, Benjamin Root wrote:
>>
>> On Wed, Feb 1, 2012 at 4:07 PM, Jim St.Cyr <jim...@gm...> wrote:
>>
>>> Hello-
>>>
>>> Scenario:
>>>
>>> Basemap used to display the East Coast of the US and the Atlantic Ocean.
>>> Shapelib is used read a shapefile the contents of is pumped into a PyPlot
>>> subplot hosted Line Collection which overlays the ocean with a grid
>>> PyPlot text is used to label each grid with it's designator.
>>>
>>> What I want to do is plot a collection of points, save the result as a
>>> PNG,
>>> clear the first set of points, plot another collection of points, save
>>> the
>>> result, and so on. The problem is the if I use the Pyplot clf function
>>> it wipes
>>> everything previously built.
>>>
>>> What do I need to do in order to clear just the points without clearing
>>> everything?
>>>
>>> Thank you.
>>>
>>> Jim
>>>
>>>
>> Jim,
>>
>> Sorry for the delay. Most plotting functions in matplotlib returns a
>> Collection object. These objects have a member function "remove()".
>>
>> >>> import matplotlib.pyplot as plt
>> >>> plt.ion()
>> >>> plt.plot([0, 1, 2, 3, 4], [4, 3, 2, 1, 0])
>> >>> pts = plt.scatter([1, 2, 3], [1, 2, 3])
>> >>> plt.show() # You see three points and a line
>> >>> res.remove()
>> >>> plt.show() # Now you see only the line
>>
>>
>> I hope that helps!
>> Ben Root
>>
>> Ben-
>>
>> Very helpful. A question, how do you determine the object designator?
>> In your example above, res.remove(), where did the 'res' come from?
>>
>> Jim
>>
>
> It was assigned when I called scatter(). Just about any mpl plotting
> function (plot(), scatter(), hist(), etc.) returns an object. Most of the
> time, users do not save the result into a variable, but if you want to do
> advanced tricks, you will need to save those returns.
>
> Ben Root
>
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Benjamin R. <ben...@ou...> - 2012年02月02日 21:00:15
On Thu, Feb 2, 2012 at 2:54 PM, Jim St.Cyr <jim...@gm...> wrote:
> On 2/2/2012 3:41 PM, Benjamin Root wrote:
>
> On Wed, Feb 1, 2012 at 4:07 PM, Jim St.Cyr <jim...@gm...> wrote:
>
>> Hello-
>>
>> Scenario:
>>
>> Basemap used to display the East Coast of the US and the Atlantic Ocean.
>> Shapelib is used read a shapefile the contents of is pumped into a PyPlot
>> subplot hosted Line Collection which overlays the ocean with a grid
>> PyPlot text is used to label each grid with it's designator.
>>
>> What I want to do is plot a collection of points, save the result as a
>> PNG,
>> clear the first set of points, plot another collection of points, save the
>> result, and so on. The problem is the if I use the Pyplot clf function
>> it wipes
>> everything previously built.
>>
>> What do I need to do in order to clear just the points without clearing
>> everything?
>>
>> Thank you.
>>
>> Jim
>>
>>
> Jim,
>
> Sorry for the delay. Most plotting functions in matplotlib returns a
> Collection object. These objects have a member function "remove()".
>
> >>> import matplotlib.pyplot as plt
> >>> plt.ion()
> >>> plt.plot([0, 1, 2, 3, 4], [4, 3, 2, 1, 0])
> >>> pts = plt.scatter([1, 2, 3], [1, 2, 3])
> >>> plt.show() # You see three points and a line
> >>> res.remove()
> >>> plt.show() # Now you see only the line
>
>
> I hope that helps!
> Ben Root
>
> Ben-
>
> Very helpful. A question, how do you determine the object designator? In
> your example above, res.remove(), where did the 'res' come from?
>
> Jim
>
It was assigned when I called scatter(). Just about any mpl plotting
function (plot(), scatter(), hist(), etc.) returns an object. Most of the
time, users do not save the result into a variable, but if you want to do
advanced tricks, you will need to save those returns.
Ben Root
From: Jim St.C. <jim...@gm...> - 2012年02月02日 20:54:40
On 2/2/2012 3:41 PM, Benjamin Root wrote:
> On Wed, Feb 1, 2012 at 4:07 PM, Jim St.Cyr <jim...@gm... 
> <mailto:jim...@gm...>> wrote:
>
> Hello-
>
> Scenario:
>
> Basemap used to display the East Coast of the US and the Atlantic Ocean.
> Shapelib is used read a shapefile the contents of is pumped into a PyPlot
> subplot hosted Line Collection which overlays the ocean with a grid
> PyPlot text is used to label each grid with it's designator.
>
> What I want to do is plot a collection of points, save the result as a PNG,
> clear the first set of points, plot another collection of points, save the
> result, and so on. The problem is the if I use the Pyplot clf function it
> wipes
> everything previously built.
>
> What do I need to do in order to clear just the points without clearing
> everything?
>
> Thank you.
>
> Jim
>
>
> Jim,
>
> Sorry for the delay. Most plotting functions in matplotlib returns a 
> Collection object. These objects have a member function "remove()".
>
> >>> import matplotlib.pyplot as plt
> >>> plt.ion()
> >>> plt.plot([0, 1, 2, 3, 4], [4, 3, 2, 1, 0])
> >>> pts = plt.scatter([1, 2, 3], [1, 2, 3])
> >>> plt.show() # You see three points and a line
> >>> res.remove()
> >>> plt.show() # Now you see only the line
>
>
> I hope that helps!
> Ben Root
>
Ben-
Very helpful. A question, how do you determine the object designator? In your 
example above, res.remove(), where did the 'res' come from?
Jim
From: Benjamin R. <ben...@ou...> - 2012年02月02日 20:42:22
On Wed, Feb 1, 2012 at 4:07 PM, Jim St.Cyr <jim...@gm...> wrote:
> Hello-
>
> Scenario:
>
> Basemap used to display the East Coast of the US and the Atlantic Ocean.
> Shapelib is used read a shapefile the contents of is pumped into a PyPlot
> subplot hosted Line Collection which overlays the ocean with a grid
> PyPlot text is used to label each grid with it's designator.
>
> What I want to do is plot a collection of points, save the result as a PNG,
> clear the first set of points, plot another collection of points, save the
> result, and so on. The problem is the if I use the Pyplot clf function it
> wipes
> everything previously built.
>
> What do I need to do in order to clear just the points without clearing
> everything?
>
> Thank you.
>
> Jim
>
>
Jim,
Sorry for the delay. Most plotting functions in matplotlib returns a
Collection object. These objects have a member function "remove()".
>>> import matplotlib.pyplot as plt
>>> plt.ion()
>>> plt.plot([0, 1, 2, 3, 4], [4, 3, 2, 1, 0])
>>> pts = plt.scatter([1, 2, 3], [1, 2, 3])
>>> plt.show() # You see three points and a line
>>> res.remove()
>>> plt.show() # Now you see only the line
I hope that helps!
Ben Root
From: Sterling S. <sm...@fu...> - 2012年02月02日 18:47:05
> Hello!
> 
> How can I zoom exactly on the same region on two different subplots at
> the same time. This option is enable when I use plotfile but not if I
> use plot, and subplots?
> 
> Thx!
> Fabien
Fabien,
When you create the new subplots, add the sharex=ax, sharey=ax keywords, where ax is the first set of axes you create.
-Sterling
From: Fabien L. <laf...@gm...> - 2012年02月02日 15:43:13
Thanks Daryl, it works!
2012年2月2日 Daryl Herzmann <ak...@ia...>:
> On Thu, Feb 2, 2012 at 8:52 AM, Fabien Lafont <laf...@gm...> wrote:
>> I don't manage to put the color of my plot in the argument' list function.
>>
>> Example:
>>
>> def function(color):
>>
>>   plot(x,y,'.', color, label = "this is my curve")
>>
>>
>> function('r')
>>
>> even if I put function(" 'r' ") it doesn't work.
>>
>> Any idea?
>
> I would suggest using named arguments for everything other than x and y, so
>
> plot(x,y,marker=',', color=color, label='this is my curve')
>
> http://matplotlib.sourceforge.net/api/axes_api.html?highlight=plot#matplotlib.axes.Axes.plot
>
> daryl
From: Daryl H. <ak...@ia...> - 2012年02月02日 15:07:32
On Thu, Feb 2, 2012 at 8:52 AM, Fabien Lafont <laf...@gm...> wrote:
> I don't manage to put the color of my plot in the argument' list function.
>
> Example:
>
> def function(color):
>
>   plot(x,y,'.', color, label = "this is my curve")
>
>
> function('r')
>
> even if I put function(" 'r' ") it doesn't work.
>
> Any idea?
I would suggest using named arguments for everything other than x and y, so
plot(x,y,marker=',', color=color, label='this is my curve')
http://matplotlib.sourceforge.net/api/axes_api.html?highlight=plot#matplotlib.axes.Axes.plot
daryl
From: Fabien L. <laf...@gm...> - 2012年02月02日 14:52:35
I don't manage to put the color of my plot in the argument' list function.
Example:
def function(color):
 plot(x,y,'.', color, label = "this is my curve")
function('r')
even if I put function(" 'r' ") it doesn't work.
Any idea?
From: Fabien L. <laf...@gm...> - 2012年02月02日 14:22:12
Thx!
2012年2月2日 Angus McMorland <am...@gm...>:
> On 2 February 2012 08:32, Fabien Lafont <laf...@gm...> wrote:
>> Hello!
>>
>> How can I zoom exactly on the same region on two different subplots at
>> the same time. This option is enable when I use plotfile but not if I
>> use plot, and subplots?
>
> Create the first axes object, then when you create subsequent ones,
> pass the first as the value of the sharex and sharey keywords to the
> subplot or add_axes command.
> See this page [1] for a quick example.
>
> Angus
>
> [1] http://matplotlib.sourceforge.net/users/recipes.html?highlight=sharex%20subplot
>
>> Thx!
>> Fabien
>>
>> ------------------------------------------------------------------------------
>> Keep Your Developer Skills Current with LearnDevNow!
>> The most comprehensive online learning library for Microsoft developers
>> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
>> Metro Style Apps, more. Free future releases when you subscribe now!
>> http://p.sf.net/sfu/learndevnow-d2d
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
> --
> AJC McMorland
> Post-doctoral research fellow
> Neurobiology, University of Pittsburgh
From: Angus M. <am...@gm...> - 2012年02月02日 13:41:28
On 2 February 2012 08:32, Fabien Lafont <laf...@gm...> wrote:
> Hello!
>
> How can I zoom exactly on the same region on two different subplots at
> the same time. This option is enable when I use plotfile but not if I
> use plot, and subplots?
Create the first axes object, then when you create subsequent ones,
pass the first as the value of the sharex and sharey keywords to the
subplot or add_axes command.
See this page [1] for a quick example.
Angus
[1] http://matplotlib.sourceforge.net/users/recipes.html?highlight=sharex%20subplot
> Thx!
> Fabien
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-- 
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh
From: Fabien L. <laf...@gm...> - 2012年02月02日 13:32:57
Hello!
How can I zoom exactly on the same region on two different subplots at
the same time. This option is enable when I use plotfile but not if I
use plot, and subplots?
Thx!
Fabien

Showing 14 results of 14

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