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






Showing 24 results of 24

From: Benjamin R. <ben...@ou...> - 2010年10月07日 20:08:41
On Thu, Oct 7, 2010 at 2:16 PM, Justin McCann <jn...@gm...> wrote:
> Sorry about that; don't know what key combo I pushed. Completed email is
> below.
>
>
> On Thu, Oct 7, 2010 at 3:09 PM, Justin McCann <jn...@gm...> wrote:
>
>> I have several heatmap images, which I place in subplots stacked
>> vertically. I've been using
>> ax = figure.add_subplot(nplots, 1, plotnum)
>> ax.imshow(...)
>>
> to add each subsequent heatmap, and then place a colorbar as another
> subplot. I'd like to annotate across all of the subplots by placing a
> vertical line (or vspan) across the entire figure-- to extend from the
> bottom figure all the way to the top, including the spaces in between. I
> thought I had seen an example of this somewhere, but couldn't find it in the
> gallery. Any suggestions?
>
> Thanks,
> Justin
>
>
You are right, I could have sworn I seen an example of that somewhere, but
this is the best I could find:
http://matplotlib.sourceforge.net/users/annotations_guide.html?highlight=annotation#using-connectorpatch
Maybe someone else knows of the "correct" way of doing this and we could get
it added to the gallery?
Ben Root
From: Tony S Yu <ts...@gm...> - 2010年10月07日 20:06:43
On Oct 7, 2010, at 3:38 PM, Waléria Antunes David wrote:
> Hi,
> 
> I did like the links below, but seeing as it was my chart.
> 
> See
> 
> My code: http://pastebin.com/KcjHAPLN
> 
> On Thu, Oct 7, 2010 at 3:08 PM, John Hunter <jd...@gm...> wrote:
> On Thu, Oct 7, 2010 at 1:01 PM, Waléria Antunes David
> <wal...@gm...> wrote:
> > I need to know how do these vertical lines on the graph. See the picture,
> > the lines circled.
> 
> We call these major and minor ticks. The major ticks are the taller
> ones, the minor ticks are the smaller ones. Their location is
> controlled by the major and minor Locator instances, and the text
> printed beside them is controlled by the major and minor formatter.
> 
> See
> 
> http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo1.html
> http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo2.html
> 
> and
> 
> http://matplotlib.sourceforge.net/search.html?q=codex+set_minor_locator
> 
> To control the tick properties themselves, see the Tick section in
> 
> http://matplotlib.sourceforge.net/users/artists.html
> 
> JDH
> 
> <graph.png>
As John mentioned, the major and minor ticks were the taller and shorter ticks, respectively. In your pasted example, you only change the minor ticks; by setting the majorLocator to same value as in the original example (i.e. 20), you only get the major tick at 0 because your data only goes to 1.5 (i.e. 20 is outside your plot range).
Also, the majorFormatter in the example is set to work with integers, but your major tick labels should be float values (since most of them are between 0 and 1). Thus, the majorFormatter code is unnecessary (commented out below).
Finally, a pet peeve: when posting example code, please make the effort to generate data for the plot so that others can easily run the code (see attached).
-Tony
#---
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
def gera_grafico(N=200, eps=1):
 x = np.abs(np.random.randn(N))
 y = 10*np.log((30*x + 1.)**(0.5)) + 34 + eps * np.random.randn(N)
 yerr = eps * np.random.randn(N)
 majorLocator = MultipleLocator(0.2)
 # majorFormatter = FormatStrFormatter('%d')
 minorLocator = MultipleLocator(0.02)
 
 fig, ax = plt.subplots()
 plt.errorbar(x, y, yerr, fmt='ob', label='date')
 plt.xlim(0.0, 1.5)
 #plt.xscale('log')
 #grid(True)
 ax.xaxis.set_major_locator(majorLocator)
 # ax.xaxis.set_major_formatter(majorFormatter)
 ax.xaxis.set_minor_locator(minorLocator)
 return fig
if __name__ == '__main__':
 gera_grafico()
 plt.show()
From: Justin M. <jn...@gm...> - 2010年10月07日 19:16:19
Sorry about that; don't know what key combo I pushed. Completed email is
below.
On Thu, Oct 7, 2010 at 3:09 PM, Justin McCann <jn...@gm...> wrote:
> I have several heatmap images, which I place in subplots stacked
> vertically. I've been using
> ax = figure.add_subplot(nplots, 1, plotnum)
> ax.imshow(...)
>
to add each subsequent heatmap, and then place a colorbar as another
subplot. I'd like to annotate across all of the subplots by placing a
vertical line (or vspan) across the entire figure-- to extend from the
bottom figure all the way to the top, including the spaces in between. I
thought I had seen an example of this somewhere, but couldn't find it in the
gallery. Any suggestions?
Thanks,
 Justin
From: Justin M. <jn...@gm...> - 2010年10月07日 19:09:57
I have several heatmap images, which I place in subplots stacked vertically.
I've been using
 ax = figure.add_subplot(nplots, 1, plotnum)
 ax.imshow(...)
to add each subsequent heatmap, and then place
From: John H. <jd...@gm...> - 2010年10月07日 18:08:57
On Thu, Oct 7, 2010 at 1:01 PM, Waléria Antunes David
<wal...@gm...> wrote:
> I need to know how do these vertical lines on the graph. See the picture,
> the lines circled.
We call these major and minor ticks. The major ticks are the taller
ones, the minor ticks are the smaller ones. Their location is
controlled by the major and minor Locator instances, and the text
printed beside them is controlled by the major and minor formatter.
See
 http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo1.html
 http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo2.html
and
 http://matplotlib.sourceforge.net/search.html?q=codex+set_minor_locator
To control the tick properties themselves, see the Tick section in
 http://matplotlib.sourceforge.net/users/artists.html
JDH
From: John H. <jd...@gm...> - 2010年10月07日 18:01:33
On Thu, Oct 7, 2010 at 12:27 PM, Michael Droettboom <md...@st...> wrote:
> You may want to look at this as well:
>
> http://matplotlib.sourceforge.net/api/mlab_api.html?highlight=csv#matplotlib.mlab.csv2rec
And these examples:
 http://matplotlib.sourceforge.net/search.html?q=codex+csv2rec
JDH
From: Eric F. <ef...@ha...> - 2010年10月07日 17:50:55
On 10/06/2010 06:18 PM, Collin Day wrote:
> I have googled around and looked through the documents, but I can't
> seem to find a description of the difference between running a script
> inside and outside ipython (using ipython --pylab). For example, I
> tried doing the following in a script and made it executable.
>
> #!/usr/bin/python
>
> from __future__ import print_function
> import matplotlib.pyplot as plt
>
> for a in xrange(0,2):
> print(a)
> plt.plot([1,2,3,4])
> plt.show()
>
>
> In ipython, it just prints 0 and 1 and shows one figure then stops.
> Outside ipython, for example just running from the command line, it
> prints 0, shows a plot, and stops to wait for me to close the plot.
> Then it prints one and shows a second plot (which is the behavior I am
> looking for).
>
> My question is how to I get the script to behave the same (as if I ran
> it fro the command line) both inside and outside ipython? If it isn't
> possible directly, is there a way to pause execution in ipython to wait
> until I close the plot before showing the next?
Colin,
I think you will find that with mpl from svn, the behavior is as you 
wish, and the same in or out of ipython (version 0.10 or higher).
Eric
>
>
> Thanks!
>
> -C
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Tony S Yu <ts...@gm...> - 2010年10月07日 17:32:34
On Oct 7, 2010, at 11:54 AM, Waléria Antunes David wrote:
> Hi,
> 
> I'm asking how to have only the vertical grid lines.?
> And I'm trying to increase the spacing in the x direction, I used the 'ax.set_xscale (' log ')', but the points were even more confused.
> Do you saw my image that sent yestarday?
> 
> Thanks,
> Waleria
I have to agree with Ben that your description is a little confusing. Looking at the plot you posted, I'm not sure what part of the plot you're interested in reproducing. I don't see any "vertical lines"; do you mean the vertical layout of the plot itself? If that's the case you can set the figure size such that it is taller than it is wide. For example, before creating your plot you can call: 
>>> import matplotlib.pyplot as plt
>>> plt.figure(figsize=(6, 8))
But from your original question, it sounds like you want the opposite, since a wider plot would stretch the x-distance between data points (logspacing stretches distances for low values, but maybe you want to stretch the distance for all values?). In this case you could just increase the width of the figure; for example:
>>> plt.figure(figsize=(12, 6))
This may not fit on your screen, though. If you're working interactively (with plt.show instead of plt.savefig) you can just resize the window to your liking.
-T
> On Wed, Oct 6, 2010 at 5:10 PM, Benjamin Root <ben...@ou...> wrote:
> 
> 
> On Wed, Oct 6, 2010 at 2:36 PM, Waléria Antunes David <wal...@gm...> wrote:
> Benjamin,
> 
> I used the 'ax.set_xscale (' log ')', but the points were even more confused. What I need is to increase from 0.0 to 0.2 points, 0.2 to 0.4 ... increase the size of the graph. However I do not know if the chart is well visualized on a monitor 20''.?
> 
> 
> Are you trying to increase the spacing in the x direction or the y direction? Log scaling is a standard trick to achieve this effect.
> 
> And how do I let my chart like this: http://www.supernova.lbl.gov/PDFs/SCP2003SNeCMBClust.pdf
> This graph format with vertical line on, something like that.
> 
> 
> Are you asking how to add a vertical line to your graph, or how to have only the vertical grid lines?
> 
> Ben Root
> 
> 
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb_______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Michael D. <md...@st...> - 2010年10月07日 17:27:20
 You may want to look at this as well:
http://matplotlib.sourceforge.net/api/mlab_api.html?highlight=csv#matplotlib.mlab.csv2rec
Mike
On 10/07/2010 01:04 PM, João Luís Silva wrote:
> On 10/07/2010 05:11 PM, Jahan Mohiuddin wrote:
>> Hi,
>>
>> I am an novice-intermediate user of python (I took a 1 semester course
>> in scientific programming with python). I wanted to know what the best
>> way is to manipulate, analyze, and plot Microsoft Excel data. The
>> methods I've looked into:
>>
>> 1. Save data in CSV file and use csv.dictreader to create a dictionary.
>> I actually couldn't figure this one out.
>>
>> 2. Read the CSV and extract the numerical data into an array of floats
>> so I can manipulate the data. This is alright but then I lose the text
>> for the header row.
>>
>>
>> I have a fairly large biological data set, but I also really just want
>> to practice with a good method. Any advice is much appreciated. Thanks!
>>
>>
>> -Jahan
>>
> You could use the python package xlrd, available at
> http://www.lexicon.net/sjmachin/xlrd.htm
>
> From what I remember the documentation wasn't all that great, but you
> should be able to access your data without too much trouble.
>
> Regards,
> João Silva
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: João L. S. <js...@fc...> - 2010年10月07日 17:05:05
On 10/07/2010 05:11 PM, Jahan Mohiuddin wrote:
> Hi,
>
> I am an novice-intermediate user of python (I took a 1 semester course
> in scientific programming with python). I wanted to know what the best
> way is to manipulate, analyze, and plot Microsoft Excel data. The
> methods I've looked into:
>
> 1. Save data in CSV file and use csv.dictreader to create a dictionary.
> I actually couldn't figure this one out.
>
> 2. Read the CSV and extract the numerical data into an array of floats
> so I can manipulate the data. This is alright but then I lose the text
> for the header row.
>
>
> I have a fairly large biological data set, but I also really just want
> to practice with a good method. Any advice is much appreciated. Thanks!
>
>
> -Jahan
>
You could use the python package xlrd, available at
http://www.lexicon.net/sjmachin/xlrd.htm
 From what I remember the documentation wasn't all that great, but you 
should be able to access your data without too much trouble.
Regards,
João Silva
From: Jahan M. <jah...@gm...> - 2010年10月07日 16:12:04
Hi,
I am an novice-intermediate user of python (I took a 1 semester course 
in scientific programming with python). I wanted to know what the 
best way is to manipulate, analyze, and plot Microsoft Excel data. 
The methods I've looked into:
1. Save data in CSV file and use csv.dictreader to create a 
dictionary. I actually couldn't figure this one out.
2. Read the CSV and extract the numerical data into an array of 
floats so I can manipulate the data. This is alright but then I lose 
the text for the header row.
I have a fairly large biological data set, but I also really just want 
to practice with a good method. Any advice is much appreciated. 
Thanks!
-Jahan
Jahan Mohiuddin
University of North Carolina at Chapel Hill, 2010
Cell: (516) 480-4825
From: Waléria A. D. <wal...@gm...> - 2010年10月07日 15:54:23
Hi,
I'm asking how to have only the vertical grid lines.?
And I'm trying to increase the spacing in the x direction, I used the
'ax.set_xscale (' log ')', but the points were even more confused.
Do you saw my image that sent yestarday?
Thanks,
Waleria
On Wed, Oct 6, 2010 at 5:10 PM, Benjamin Root <ben...@ou...> wrote:
>
>
> On Wed, Oct 6, 2010 at 2:36 PM, Waléria Antunes David <
> wal...@gm...> wrote:
>
>> Benjamin,
>>
>> I used the 'ax.set_xscale (' log ')', but the points were even more
>> confused. What I need is to increase from 0.0 to 0.2 points, 0.2 to 0.4 ...
>> increase the size of the graph. However I do not know if the chart is well
>> visualized on a monitor 20''.?
>>
>>
> Are you trying to increase the spacing in the x direction or the y
> direction? Log scaling is a standard trick to achieve this effect.
>
>
>> And how do I let my chart like this:
>> http://www.supernova.lbl.gov/PDFs/SCP2003SNeCMBClust.pdf
>> This graph format with vertical line on, something like that.
>>
>>
> Are you asking how to add a vertical line to your graph, or how to have
> only the vertical grid lines?
>
> Ben Root
>
>
From: Michael D. <md...@st...> - 2010年10月07日 14:20:23
 Thanks for bringing this to my attention. The fix was for symlog, but 
inadvertently broke log. Your suggested fix is nice, but it doesn't 
have exactly the same behavior as what it used to do. My fix (in r8733) 
is to basically restore the old code in the case of regular log, and 
only use the new code for symlog.
Mike
On 10/07/2010 06:19 AM, Matthias Michler wrote:
> On Thursday October 7 2010 12:06:26 Matthias Michler wrote:
>> Hello list,
>>
>> I run into trouble with the resent svn version using logarithmic scaling as
>> before. This is probably due to the changes from rev 8730 to 8732, where in
>> the ticker,py the line
>>
>> ticklocs = self._transform. ...
>>
>> was added.
>>
>> Running my program I get the following AttributeError:
>> File "/scratch/michler/SOFT/lib/python2.6/site-
>> packages/matplotlib/ticker.py", line 1272, in __call__
>> ticklocs = self._transform.inverted().transform(decades)
>> AttributeError: LogLocator instance has no attribute '_transform'
>>
>> Did I miss anything or is this new feature in an unstable state?
> Hello list,
>
> I would like to propose the attached patch for the error I encountered
> recently.
>
> Could anybody check this, please?
>
> Kind regards and thanks in advance,
> Matthias
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Waléria A. D. <wal...@gm...> - 2010年10月07日 11:17:15
How to have only the vertical grid lines.?
And I trying to increase the spacing in the x direction, I used the
'ax.set_xscale (' log ')', but the points were even more confused. Do you
saw my image that sent yestarday?
On Wed, Oct 6, 2010 at 5:10 PM, Benjamin Root <ben...@ou...> wrote:
>
>
> On Wed, Oct 6, 2010 at 2:36 PM, Waléria Antunes David <
> wal...@gm...> wrote:
>
>> Benjamin,
>>
>> I used the 'ax.set_xscale (' log ')', but the points were even more
>> confused. What I need is to increase from 0.0 to 0.2 points, 0.2 to 0.4 ...
>> increase the size of the graph. However I do not know if the chart is well
>> visualized on a monitor 20''.?
>>
>>
> Are you trying to increase the spacing in the x direction or the y
> direction? Log scaling is a standard trick to achieve this effect.
>
>
>> And how do I let my chart like this:
>> http://www.supernova.lbl.gov/PDFs/SCP2003SNeCMBClust.pdf
>> This graph format with vertical line on, something like that.
>>
>>
> Are you asking how to add a vertical line to your graph, or how to have
> only the vertical grid lines?
>
> Ben Root
>
>
From: Matthias M. <Mat...@gm...> - 2010年10月07日 10:26:07
Hello list,
I run into trouble with the resent svn version using logarithmic scaling as 
before. This is probably due to the changes from rev 8730 to 8732, where in 
the ticker,py the line 
ticklocs = self._transform. ...
was added.
Running my program I get the following AttributeError:
 File "/scratch/michler/SOFT/lib/python2.6/site-
packages/matplotlib/ticker.py", line 1272, in __call__
 ticklocs = self._transform.inverted().transform(decades)
AttributeError: LogLocator instance has no attribute '_transform'
Did I miss anything or is this new feature in an unstable state?
Kind regards,
Matthias
From: Matthias M. <Mat...@gm...> - 2010年10月07日 10:20:26
Attachments: ticker_rev8732.patch
On Thursday October 7 2010 12:06:26 Matthias Michler wrote:
> Hello list,
> 
> I run into trouble with the resent svn version using logarithmic scaling as
> before. This is probably due to the changes from rev 8730 to 8732, where in
> the ticker,py the line
> 
> ticklocs = self._transform. ...
> 
> was added.
> 
> Running my program I get the following AttributeError:
> File "/scratch/michler/SOFT/lib/python2.6/site-
> packages/matplotlib/ticker.py", line 1272, in __call__
> ticklocs = self._transform.inverted().transform(decades)
> AttributeError: LogLocator instance has no attribute '_transform'
> 
> Did I miss anything or is this new feature in an unstable state?
Hello list,
I would like to propose the attached patch for the error I encountered 
recently.
Could anybody check this, please?
Kind regards and thanks in advance,
Matthias
From: Collin D. <dcd...@gm...> - 2010年10月07日 04:18:29
I have googled around and looked through the documents, but I can't
seem to find a description of the difference between running a script
inside and outside ipython (using ipython --pylab). For example, I
tried doing the following in a script and made it executable.
#!/usr/bin/python
from __future__ import print_function
import matplotlib.pyplot as plt
for a in xrange(0,2):
 print(a)
 plt.plot([1,2,3,4])
 plt.show()
In ipython, it just prints 0 and 1 and shows one figure then stops.
Outside ipython, for example just running from the command line, it
prints 0, shows a plot, and stops to wait for me to close the plot.
Then it prints one and shows a second plot (which is the behavior I am
looking for).
My question is how to I get the script to behave the same (as if I ran
it fro the command line) both inside and outside ipython? If it isn't
possible directly, is there a way to pause execution in ipython to wait
until I close the plot before showing the next?
Thanks!
-C
From: Jae-Joon L. <lee...@gm...> - 2010年10月07日 01:02:10
With the current svn, the code works as expected.
So, I guess this is an issue that has been fixed.
Can you try something like below and see if this works?
 for tck in ax2.get_yticklabels():
 tck.set_fontsize(34)
Regards,
-JJ
On Wed, Oct 6, 2010 at 9:50 AM, Michael Lenander <jer...@gm...> wrote:
>
> I'm making a plot with two y axes. When I resize the font on the tick
> labels for the second axis, nothing happens. The same code however works
> fine for the first set of axes.
>
>  fig = figure()
>  ax1 = fig.add_subplot(111)
>  plot(bias,gamma1,'k.',markersize=mrkrsize)
>  ax1.set_ylim([0,10])
>  ax1.set_yticks([0,5,10])
>  ax1.set_yticklabels([0,5,10],fontsize=34) #Correctly sets tick label
> font size
>
>  ax2 = ax1.twinx()
>  plot(bias,f,'k.',markersize=mrkrsize)
>  ax2.set_yticks([0,-2,-4,-6])
>  ax2.set_yticklabels([0,-2,-4,-6],fontsize=34) #Remains default size, no
> error message
>
> As far as I can tell this really should work, unless there is something
> about twinx I don't understand. Any insight would be appreciated.
> --
> View this message in context: http://old.nabble.com/Problem-with-set_yticklabels-tp29892687p29892687.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Benjamin R. <ben...@ou...> - 2010年10月07日 00:56:46
On Wed, Oct 6, 2010 at 7:31 PM, Michael Cracraft <mic...@gm...
> wrote:
> You are correct about the version. I was just working with the version
> installed on Fedora 13, and the recache works. Looks like a working
> solution for now.
>
> Thanks,
> Michael
>
>
Just as a side note because 'tis the season for Linux upgrades... It looks
like Jef Spaleta has packaged the version 1.0 of mpl for the upcoming Fedora
14 release (early Nov.). However, Ubuntu 10.10 (Maverick Meerkat) will be
released in a few days with version 0.99.3. Is this because Ubuntu
typically follows whatever is in the Debian repos?
Ben Root
From: Jae-Joon L. <lee...@gm...> - 2010年10月07日 00:50:35
On Tue, Oct 5, 2010 at 11:07 PM, Alessio Civ <via...@gm...> wrote:
>
> Hi,
>
> I'm trying to make a scatter plot of 2 variables using a thirds as filter to
> have different colors.
>
> Let's say I have those data:
>
> x=1,2,3,4
> y=2,3,4,5
> z=0,1,0,1
>
> Then I want the values of x and y corresponding to those of z=0 to be of a
> color and those corresponding to z=1 to be of another color.
>
> This is the code I manage to do until know:
>
>
> import xlrd
> import numpy as np
> import matplotlib.pyplot as plt
>
> wb = xlrd.open_workbook('GBL2009.xls')
> sh = wb.sheet_by_index(0)
>
> def column_pos():
>  first_row=sh.row_values(0)
>  net_p=""
>  for i in first_row:
>    if i=='net_price':
>      net_p=first_row.index(i) #In gets the column position
>  for i in first_row:
>    if i=='material':
>      mat_p=first_row.index(i) #In gets the column position
>  for i in first_row:
>    if i=='qty':
>      qty_p=first_row.index(i) #In gets the column position
>  print net_p, mat_p, qty_p
>  #filtering(net_p, mat_p, qty_p)
>  test(net_p, mat_p, qty_p)
>
>
> def test(net_p, mat_p, qty_p):
>  list=[]
>  for rownum in range(sh.nrows):
>    if sh.cell(rownum,mat_p).value in (96433890, 96433886):
>      list.append(sh.row_values(rownum))
>
>  x=[]
>  y=[]
>  z=[]
>  for i in list:
>    x.append(i[qty_p])
>    y.append(i[net_p])
>    z.append(i[mat_p])
>
>  fig = plt.figure(1, figsize=(5.5,5.5))
>  axScatter = plt.subplot(111)
>
>  colors = ('r', 'g', 'b', 'k')
>  for c in colors:
>    axScatter.scatter(x, y, c=c, marker='s')
>
>  plt.show()
>
So, what is your problem?
If you want to post a code, please post a complete (but simple!) code.
If you want to map values of z to colors, a simple solution would be
to use dict.
z = [0,1,0,1]
color_map = {0:"r", 1:"g"}
z_as_colors = map(color_map.get, z)
scatter supports colormap but it may not very useful for your case.
Regards,
-JJ
From: Jae-Joon L. <lee...@gm...> - 2010年10月07日 00:40:54
The pdf backend rely on the "tell" method of a given file object,
which (I think) is not supported by stdout.
As a workaround, you may use StringIO.
from cStringIO import StringIO
outs = StringIO()
plt.savefig(outs, format='pdf')
print os.getvalue()
Regards,
-JJ
On Fri, Oct 1, 2010 at 8:59 PM, damiano michael
<dam...@wa...> wrote:
> hi !
>
> i would like to write a server side python script that generate .pdf
> documents.
>
> for the moment i have Python 2.7 installed server side
> and matplolib installed server side too.
>
> A simple script that create a simple plot and generate a .png picture
> works.
>
> this is the script i use :
>
> #-------------------------------------------
>
> # to access standard output :
>
> import sys
>
>
>
> # select a non-GUI backend :
>
> import matplotlib
>
> matplotlib.use('Agg')
> #matplotlib.use("cairo.pdf")
>
> #matplotlib.use('PDF')
>
>
>
>
> # import plotting module :
>
> import matplotlib.pyplot as plt
>
>
>
> # generate the plot :
>
> plt.plot([1,2,3,2,3,4])
>
>
> # print the content type (what's the data type)
>
> # the new line is embedded, using '\n' notation :
> print "Content-Type: image/png\n"
> # print "Content-Type: image/PDF\n"
> # print "Content-type: application/pdf"
>
>
>
> # output directly to webserver, as a png file
> :
> plt.savefig(sys.stdout, format='png')
>
>
> # plt.savefig(sys.stdout, format='PDF')
>
>
>
> # plt.savefig( "test.pdf", format='pdf' )
>
> #-----------------------------------------------
>
> I am wondering how to do the same thing but with sending a pdf file
> instead of
> a png picture. (the # are for all the things i tried)
>
> Does someone know ?
>
> thanks.
>
> jean-claude
>
>
>
> ------------------------------------------------------------------------------
> Virtualization is moving to the mainstream and overtaking non-virtualized
> environment for deploying applications. Does it make network security
> easier or more difficult to achieve? Read this whitepaper to separate the
> two and get a better understanding.
> http://p.sf.net/sfu/hp-phase2-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Michael C. <mic...@gm...> - 2010年10月07日 00:32:07
You are correct about the version. I was just working with the version
installed on Fedora 13, and the recache works. Looks like a working
solution for now.
Thanks,
Michael
On Wed, Oct 6, 2010 at 8:18 PM, Jae-Joon Lee <lee...@gm...> wrote:
> I believe that you're using older version of mpl (<1.0) and this is a
> known issues, which has been fixed.
>
>
> http://sourceforge.net/tracker/?func=detail&aid=2917758&group_id=80706&atid=560720
>
> Try to add
>
> L1.recache()
>
> after set_ydata.
>
> Regards,
>
> -JJ
>
>
>
> On Thu, Oct 7, 2010 at 3:06 AM, Michael Cracraft
> <mic...@gm...> wrote:
> > I have a code that continuously modifies a numpy.ndarray variable. Then,
> I
> > use set_ydata on the matplotlib.lines.Line2D object to the same ndarray
> > variable. Then, I call fig.canvas.draw() to redraw the figure, where fig
> is
> > Figure object.
> >
> > However, the line on the graph never changes. I print a few entries to
> the
> > console to make sure that the variable is changing.
> >
> > It seems like the only way I can get the line to update is to create a
> > completely new ndarray, update that variable with the new values and use
> > set_ydata on my line object. Then, the redraw works. Other things that
> I
> > tried that didn't seem to work were:
> >
> > L1.set_ydata(x[:])
> > L1.set_ydata(x.tolist())
> > L1.set_ydata(list(x))
> >
> >
> > where L1 is my line object, and x is my ndarray. To make it redraw I
> have
> > to do something like this.
> >
> > xnew = numpy.zeros(numpy.size(x,0))
> > for k in range(numpy.size(x,0)):
> > xnew[k] = x[k]
> > L1.set_ydata(xnew)
> > fig.canvas.draw()
> >
> > Is there some switch I can set to force a redraw of the elements? I feel
> > like I am missing something fundamental.
> >
> > Thanks,
> > Michael
> >
> > --
> > _____________________________________________
> >
> >
> ------------------------------------------------------------------------------
> > Beautiful is writing same markup. Internet Explorer 9 supports
> > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
> > Spend less time writing and rewriting code and more time creating great
> > experiences on the web. Be a part of the beta today.
> > http://p.sf.net/sfu/beautyoftheweb
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
>
-- 
_____________________________________________
From: Michael C. <mic...@gm...> - 2010年10月07日 00:20:12
I am running python 2.6.4 and matplotlib 0.99.1.1. I was using the TkAgg
backend with my original problem, but I tried GTKAgg with the same result.
Here are two sample codes. One works and the other does not.
This one works ...
plt.ion()
x = np.arange(0,2*np.pi,0.01)
y = np.sin(x)
line, = plt.plot(x,y)
for i in np.arange(1,200):
 y = np.sin(x + i/10.0)
 line.set_ydata(y)
 plt.draw()
This one does not ...
plt.ion()
x = np.arange(0,2*np.pi,0.01)
y = np.sin(x)
line, = plt.plot(x,y)
for i in np.arange(1,200):
 for k in range(len(x)):
 y[k] = np.sin(x[k] + i/10.0)
 line.set_ydata(y)
 plt.draw()
The only real difference is that I do not get a new ndarray instance in the
second one. My guess was that there was something to do with the object
being the same instance as before causing some issue when I updated the
ydata.
On Wed, Oct 6, 2010 at 7:56 PM, Benjamin Root <ben...@ou...> wrote:
> On Wed, Oct 6, 2010 at 1:06 PM, Michael Cracraft <
> mic...@gm...> wrote:
>
>> I have a code that continuously modifies a numpy.ndarray variable. Then,
>> I use set_ydata on the matplotlib.lines.Line2D object to the same ndarray
>> variable. Then, I call fig.canvas.draw() to redraw the figure, where fig is
>> Figure object.
>>
>> However, the line on the graph never changes. I print a few entries to
>> the console to make sure that the variable is changing.
>>
>> It seems like the only way I can get the line to update is to create a
>> completely new ndarray, update that variable with the new values and use
>> set_ydata on my line object. Then, the redraw works. Other things that I
>> tried that didn't seem to work were:
>>
>> L1.set_ydata(x[:])
>> L1.set_ydata(x.tolist())
>> L1.set_ydata(list(x))
>>
>>
>> where L1 is my line object, and x is my ndarray. To make it redraw I have
>> to do something like this.
>>
>> xnew = numpy.zeros(numpy.size(x,0))
>> for k in range(numpy.size(x,0)):
>> xnew[k] = x[k]
>> L1.set_ydata(xnew)
>> fig.canvas.draw()
>>
>> Is there some switch I can set to force a redraw of the elements? I feel
>> like I am missing something fundamental.
>>
>> Thanks,
>> Michael
>>
>>
> Michael,
>
> Which version of matplotlib are you using? Which backend are you using?
> Also, could you include a small script or two that demonstrate the problem?
> This way, we can poke around with it and see what is up.
>
> Ben Root
>
>
-- 
_____________________________________________
From: Jae-Joon L. <lee...@gm...> - 2010年10月07日 00:19:16
I believe that you're using older version of mpl (<1.0) and this is a
known issues, which has been fixed.
http://sourceforge.net/tracker/?func=detail&aid=2917758&group_id=80706&atid=560720
Try to add
L1.recache()
after set_ydata.
Regards,
-JJ
On Thu, Oct 7, 2010 at 3:06 AM, Michael Cracraft
<mic...@gm...> wrote:
> I have a code that continuously modifies a numpy.ndarray variable. Then, I
> use set_ydata on the matplotlib.lines.Line2D object to the same ndarray
> variable. Then, I call fig.canvas.draw() to redraw the figure, where fig is
> Figure object.
>
> However, the line on the graph never changes. I print a few entries to the
> console to make sure that the variable is changing.
>
> It seems like the only way I can get the line to update is to create a
> completely new ndarray, update that variable with the new values and use
> set_ydata on my line object. Then, the redraw works. Other things that I
> tried that didn't seem to work were:
>
> L1.set_ydata(x[:])
> L1.set_ydata(x.tolist())
> L1.set_ydata(list(x))
>
>
> where L1 is my line object, and x is my ndarray. To make it redraw I have
> to do something like this.
>
> xnew = numpy.zeros(numpy.size(x,0))
> for k in range(numpy.size(x,0)):
>   xnew[k] = x[k]
> L1.set_ydata(xnew)
> fig.canvas.draw()
>
> Is there some switch I can set to force a redraw of the elements? I feel
> like I am missing something fundamental.
>
> Thanks,
> Michael
>
> --
> _____________________________________________
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
2 messages has been excluded from this view by a project administrator.

Showing 24 results of 24

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