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

Showing 13 results of 13

From: volcs0 <vo...@gm...> - 2008年02月02日 21:42:09
Perfect. Thank you.
I saw a reference to this hack in the 2005 post, but the linked forum post
was inaccessible to me (as a non-developer).
Thanks again.
John Hunter-4 wrote:
> 
> On Feb 2, 2008 3:06 PM, Eric Firing <ef...@ha...> wrote:
>> volcs0 wrote:
>> > I saw one post related to arbitrary axis positioning from 2005, but
>> there was
>> > no solution.
>>
>> It is still on the wish list.
> 
> Though with a little hacking, you can emulate it by manually drawing
> everything yourself -- this is the approach SAGE takes. Eg,
> 
> import numpy as np
> from pylab import figure, show
> import matplotlib.lines as lines
> 
> def make_xaxis(ax, yloc, offset=0.05, **props):
> xmin, xmax = ax.get_xlim()
> locs = [loc for loc in ax.xaxis.get_majorticklocs()
> if loc>=xmin and loc<=xmax]
> tickline, = ax.plot(locs, [yloc]*len(locs),linestyle='',
> marker=lines.TICKDOWN, **props)
> axline, = ax.plot([xmin, xmax], [yloc, yloc], **props)
> tickline.set_clip_on(False)
> axline.set_clip_on(False)
> for loc in locs:
> ax.text(loc, yloc-offset, '%1.1f'%loc,
> horizontalalignment='center',
> verticalalignment='top')
> 
> def make_yaxis(ax, xloc=0, offset=0.05, **props):
> ymin, ymax = ax.get_ylim()
> locs = [loc for loc in ax.yaxis.get_majorticklocs()
> if loc>=ymin and loc<=ymax]
> tickline, = ax.plot([xloc]*len(locs), locs, linestyle='',
> marker=lines.TICKLEFT, **props)
> axline, = ax.plot([xloc, xloc], [ymin, ymax], **props)
> tickline.set_clip_on(False)
> axline.set_clip_on(False)
> 
> for loc in locs:
> ax.text(xloc-offset, loc, '%1.1f'%loc,
> verticalalignment='center',
> horizontalalignment='right')
> 
> 
> props = dict(color='black', linewidth=2, markeredgewidth=2)
> x = np.arange(200.)
> y = np.sin(2*np.pi*x/200.) + np.random.rand(200)-0.5
> fig = figure(facecolor='white')
> ax = fig.add_subplot(111, frame_on=False)
> ax.axison = False
> ax.plot(x, y, 'd', markersize=8, markerfacecolor='blue')
> ax.set_xlim(0, 200)
> ax.set_ylim(-1.5, 1.5)
> make_xaxis(ax, 0, offset=0.1, **props)
> make_yaxis(ax, 0, offset=5, **props)
> fig.savefig('manual_axis.png', dpi=100, facecolor='white',
> edgecolor='white')
> show()
> 
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://www.nabble.com/Can-I-change-placement-of-X-Axis--tp15246318p15247656.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: John H. <jd...@gm...> - 2008年02月02日 21:27:54
Attachments: test.py manual_axis.png
On Feb 2, 2008 3:06 PM, Eric Firing <ef...@ha...> wrote:
> volcs0 wrote:
> > I saw one post related to arbitrary axis positioning from 2005, but there was
> > no solution.
>
> It is still on the wish list.
Though with a little hacking, you can emulate it by manually drawing
everything yourself -- this is the approach SAGE takes. Eg,
import numpy as np
from pylab import figure, show
import matplotlib.lines as lines
def make_xaxis(ax, yloc, offset=0.05, **props):
 xmin, xmax = ax.get_xlim()
 locs = [loc for loc in ax.xaxis.get_majorticklocs()
 if loc>=xmin and loc<=xmax]
 tickline, = ax.plot(locs, [yloc]*len(locs),linestyle='',
 marker=lines.TICKDOWN, **props)
 axline, = ax.plot([xmin, xmax], [yloc, yloc], **props)
 tickline.set_clip_on(False)
 axline.set_clip_on(False)
 for loc in locs:
 ax.text(loc, yloc-offset, '%1.1f'%loc,
 horizontalalignment='center',
 verticalalignment='top')
def make_yaxis(ax, xloc=0, offset=0.05, **props):
 ymin, ymax = ax.get_ylim()
 locs = [loc for loc in ax.yaxis.get_majorticklocs()
 if loc>=ymin and loc<=ymax]
 tickline, = ax.plot([xloc]*len(locs), locs, linestyle='',
 marker=lines.TICKLEFT, **props)
 axline, = ax.plot([xloc, xloc], [ymin, ymax], **props)
 tickline.set_clip_on(False)
 axline.set_clip_on(False)
 for loc in locs:
 ax.text(xloc-offset, loc, '%1.1f'%loc,
 verticalalignment='center',
 horizontalalignment='right')
props = dict(color='black', linewidth=2, markeredgewidth=2)
x = np.arange(200.)
y = np.sin(2*np.pi*x/200.) + np.random.rand(200)-0.5
fig = figure(facecolor='white')
ax = fig.add_subplot(111, frame_on=False)
ax.axison = False
ax.plot(x, y, 'd', markersize=8, markerfacecolor='blue')
ax.set_xlim(0, 200)
ax.set_ylim(-1.5, 1.5)
make_xaxis(ax, 0, offset=0.1, **props)
make_yaxis(ax, 0, offset=5, **props)
fig.savefig('manual_axis.png', dpi=100, facecolor='white', edgecolor='white')
show()
From: Eric F. <ef...@ha...> - 2008年02月02日 21:06:27
volcs0 wrote:
> I saw one post related to arbitrary axis positioning from 2005, but there was
> no solution.
It is still on the wish list.
Eric
> 
> I'd like to generate a plot similar to this:
> 
> http://www.nabble.com/file/p15246318/250027952-L.png 
> 
> Is there a way to move the X-axis to Y=0 - and remove the bounding box?
> 
> Thanks.
> 
From: volcs0 <vo...@gm...> - 2008年02月02日 19:32:34
I saw one post related to arbitrary axis positioning from 2005, but there was
no solution.
I'd like to generate a plot similar to this:
http://www.nabble.com/file/p15246318/250027952-L.png 
Is there a way to move the X-axis to Y=0 - and remove the bounding box?
Thanks.
-- 
View this message in context: http://www.nabble.com/Can-I-change-placement-of-X-Axis--tp15246318p15246318.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Wayne E. H. <wh...@pa...> - 2008年02月02日 18:30:41
Mark Bakker wrote:
> Yet here you claim that 1pt = 1/72 inch.
> Is that always the case?
Kind of. This is a typesetting measurement originally having nothing to 
do with computers, displays or graphics files. However at Wikipedia 
they say its definition has changed over time.
http://en.wikipedia.org/wiki/Point_%28typography%29
From: <pn...@ui...> - 2008年02月02日 01:59:30
Included is a patch to change the behavior when legend() is called with numpoints less than or equal to 0. Currently if one makes such a call, some cryptic error messages are printed out and the plot is not generated.
The included patch produces a warning, and defaults to using numpoints = 4, so the plot is actually made.
Paul Novak
---
--- legend.py	2008年02月01日 19:14:24.000000000 -0600
+++ legend.py	2008年02月01日 19:13:55.000000000 -0600
@@ -166,6 +166,12 @@
 
 self._loc = loc
 
+ if self.numpoints <= 0:
+ warnings.warn('legend() called with numpoints = %d. '
+ 'Default to numpoints = 4 because numpoints must be greater than zero.' \
+ % (self.numpoints))
+ self.numpoints = 4
+
 self.legendPatch = Rectangle(
 xy=(0.0, 0.0), width=0.5, height=0.5,
 facecolor='w', edgecolor='k',
From: <pn...@ui...> - 2008年02月02日 01:59:17
When using the PostScript backend, and plotting several lines with the same call to plot (or when plotting a LineCollection), kwargs are applied to the first line only, and not to every line.
Included is a minimal script that exhibits this problem. The saved figure shows only one thick red line where we would expect two such lines.
Paul Novak
#!/usr/bin/env python
import matplotlib
matplotlib.use('PS')
from pylab import *
x = arange(0.0, 5.0)
y = 2 * x
plot(x, x, x, y, color='red', linewidth = 5)
savefig('image')
show()
From: Eric F. <ef...@ha...> - 2008年02月02日 01:53:45
Rich Shepard wrote:
> On Fri, 1 Feb 2008, Eric Firing wrote:
> 
>> What changed is that I added a warning where previously there was only a
>> silent error--the matplotlib.use command was being ignored. Sometimes
>> this (ignoring the command) is harmless, but it is never the user's intent
>> and in some cases it can cause puzzling problems. It often occurs when a
>> script or module does "from pylab import *" or "import pylab as P", and
>> then later "import matplotlib; matplotlib.use('Agg')". In this example,
>> the user intends to make plots non-interactively, writing them to files,
>> but the whole gui machinery for the default backend (e.g., gtkagg or wxagg
>> or tkagg) is imported unintentionally.
> 
> Eric,
> 
> Thanks for the explanation. And you bring up another issue that I have:
> the most appropriate way to generate non-interactive plots, written to
> files, for inclusion in a ReportLab report. Do I want to use pylab for this,
> plots embedded in wx, or something else?
If you are generating plots non-interactively--that is, entirely in a 
script, so you don't need to see the plot on the screen to fiddle with 
it--then use a non-interactive backend. WxAgg, TkAgg, GtkAgg, QtAgg, 
etc. are needed only if you are working interactively. They don't 
necessarily hurt otherwise, but they don't help.
I have taken a quick look at the ReportLab documentation, and it looks 
like you are stuck with using PIL to import png files. (This means using 
the Agg backend.) If what you are plotting is image-like, this is not so 
bad, but it is not great in any case. It means things like text in your 
plot (axes ticks, labels, etc.) that should be getting into your final 
pdf in native form will instead get in as bit patterns, and this is bad 
for both quality and file size. Same for lines; it would be much better 
to generate vector graphics directly in your report. It would be nice 
to have something like a pdf-to-reportlab or svg-to-reportlab code 
generator, so you could use the pdf or svn matplotlib backend, and keep 
vectors as vectors.
If your matplotlib plots can be on separate pages, then you could use 
the pdf backend to generate those pages, and use pdftk to insert them 
among the pages generated by ReportLab.
Whether to use pylab is an entirely separate issue; it is a matter of 
programming style. The usual advice would be to use matplotlib.pyplot 
for a very few functions (figure, close, maybe a few others) and then 
use object-oriented style--that is, object method calls instead of 
functions--for everything else. There is nothing wrong with sticking 
with pylab or pyplot functions, though--they work fine.
> 
> I need to get this module running properly so I am focusing on really
> understanding how to use matplotlib to produce what we need.
> 
>> One way to find out where the warning is coming from is to invoke your script 
>> as
>>
>> python -Werror myscript.py
>>
>> which will turn the warning into an error and thereby trigger an exception 
>> traceback.
> 
> OK. Tomorrow morning I'll do this.
> 
>> What this will *not* tell you is where the *earlier* call to
>> matplotlib.use() is occurring. To find it you will have to trace back
Note the following three lines carefully:
>> through your application, looking for the first place where pylab,
>> matplotlib.pyplot, or matplotlib.backends is imported, or the first
>> explicit use of matplotlib.use(), whichever is earliest.
Where and when matplotlib itself is imported doesn't matter--it is the 
events listed above that are relevant to your question.
Eric
> 
> There are two modules in which pylab is used: reports.py and functions.py.
> The former calls specific matplotlib functions in the latter.
> 
> On the other hand, matplotlib is imported in several modules. Perhaps
> that's the problem. I'll check this tomorrow, too.
> 
> Thanks,
> 
> Rich
> 
From: Rich S. <rsh...@ap...> - 2008年02月02日 01:33:07
On Fri, 1 Feb 2008, Eric Firing wrote:
> One way to find out where the warning is coming from is to invoke your script 
> as
>
> python -Werror myscript.py
Eric,
 That did the trick. Two modules needed to have the backend specification
commented out.
Many thanks,
Rich
-- 
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
From: Rich S. <rsh...@ap...> - 2008年02月02日 01:14:56
On Fri, 1 Feb 2008, Eric Firing wrote:
> What changed is that I added a warning where previously there was only a
> silent error--the matplotlib.use command was being ignored. Sometimes
> this (ignoring the command) is harmless, but it is never the user's intent
> and in some cases it can cause puzzling problems. It often occurs when a
> script or module does "from pylab import *" or "import pylab as P", and
> then later "import matplotlib; matplotlib.use('Agg')". In this example,
> the user intends to make plots non-interactively, writing them to files,
> but the whole gui machinery for the default backend (e.g., gtkagg or wxagg
> or tkagg) is imported unintentionally.
Eric,
 Thanks for the explanation. And you bring up another issue that I have:
the most appropriate way to generate non-interactive plots, written to
files, for inclusion in a ReportLab report. Do I want to use pylab for this,
plots embedded in wx, or something else?
 I need to get this module running properly so I am focusing on really
understanding how to use matplotlib to produce what we need.
> One way to find out where the warning is coming from is to invoke your script 
> as
>
> python -Werror myscript.py
>
> which will turn the warning into an error and thereby trigger an exception 
> traceback.
 OK. Tomorrow morning I'll do this.
> What this will *not* tell you is where the *earlier* call to
> matplotlib.use() is occurring. To find it you will have to trace back
> through your application, looking for the first place where pylab,
> matplotlib.pyplot, or matplotlib.backends is imported, or the first
> explicit use of matplotlib.use(), whichever is earliest.
 There are two modules in which pylab is used: reports.py and functions.py.
The former calls specific matplotlib functions in the latter.
 On the other hand, matplotlib is imported in several modules. Perhaps
that's the problem. I'll check this tomorrow, too.
Thanks,
Rich
-- 
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
From: Anthony F. <ant...@gm...> - 2008年02月02日 01:12:27
On Jan 31, 2008 6:03 AM, Thomas Tanner <ta...@tu...> wrote:
> Hi,
> I'd like to have figure with 3 (or 4) plots having different scales
> but sharing the same x-axis.
> Basically I want an extension of the twinx command (see, e.g,
> two_scales.py demo).
> I'm using 0.91.2svn on MacOSX10.5.1 from http://trichech.us/?page_id=5
[snip]
> The 4th plot overwrites the ylim of the 1st plot (bug?).
> Is there a limit of 3 axes per figure?
> The ylim of plot4 is still ignored.
> Why do I have to add the axes a1 and a4 the main axes to make them visible?
I'm working on an app that has 8 axes per figure (X1, X2, Y1 ... Y4)
and it works fine. Well, the MPL bits do.
One of the unexpected things that we had to do in order to get the
multiple plots to work as expected was to ensure that each additional
subplot had its own label. MPL has some 'helper' code that tries to
consolidate the axes so that if you create two axes with identical
parameters, you only end up with one axes object (I think -- someone
more knowledgeable can fill you in on the details).
Now, we do things using the API rather than using pylab, some I'm not
entirely certain (and haven't tested it) but I think that the pylab
command 'axes' has an optional argument of 'label', which you should
set to be a unique string for each subplot.
I've only scanned through your code, and I'm not at all familiar with
the pylab syntax, but I'm puzzled that you haven't used twinx (or in
API parlance, sharex) anywhere. Regardless, the API code for
overlaying subplots is of the form:
figure.add_axes(axes1.get_position(), sharex=axes1, frameon=False,
label='someUniqueString')
Hope this helps,
Anthony.
From: Eric F. <ef...@ha...> - 2008年02月02日 00:49:59
Rich Shepard wrote:
> I just upgraded my Slackware-11.0 workstation from matplotlib-0.90.1 to
> -0.91.2. When I now start my application I see this:
> 
> /usr/lib/python2.4/site-packages/matplotlib/__init__.py:753: UserWarning:
> This call to matplotlib.use() has no effect
> because the the backend has already been chosen;
> matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
> or matplotlib.backends is imported for the first time.
> 
> warnings.warn(_use_error_msg)
> 
> I don't know to which matplotlib.use() call the message refers. At the top
> of the module in which matplotlib is used I have
> matplotlib.use('WXAgg')
> 
> and the above warning did not appear with the prior version of the library.
> 
> Please help me to understand what changed, and how to fix the change so
> the warning no longer appears.
What changed is that I added a warning where previously there was only a 
silent error--the matplotlib.use command was being ignored. Sometimes 
this (ignoring the command) is harmless, but it is never the user's 
intent and in some cases it can cause puzzling problems. It often 
occurs when a script or module does "from pylab import *" or "import 
pylab as P", and then later "import matplotlib; matplotlib.use('Agg')". 
In this example, the user intends to make plots non-interactively, 
writing them to files, but the whole gui machinery for the default 
backend (e.g., gtkagg or wxagg or tkagg) is imported unintentionally.
One way to find out where the warning is coming from is to invoke your 
script as
python -Werror myscript.py
which will turn the warning into an error and thereby trigger an 
exception traceback.
What this will *not* tell you is where the *earlier* call to 
matplotlib.use() is occurring. To find it you will have to trace back 
through your application, looking for the first place where pylab, 
matplotlib.pyplot, or matplotlib.backends is imported, or the first 
explicit use of matplotlib.use(), whichever is earliest.
Eric
From: Rich S. <rsh...@ap...> - 2008年02月02日 00:12:43
 I just upgraded my Slackware-11.0 workstation from matplotlib-0.90.1 to
-0.91.2. When I now start my application I see this:
/usr/lib/python2.4/site-packages/matplotlib/__init__.py:753: UserWarning:
This call to matplotlib.use() has no effect
because the the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
 warnings.warn(_use_error_msg)
 I don't know to which matplotlib.use() call the message refers. At the top
of the module in which matplotlib is used I have
 matplotlib.use('WXAgg')
and the above warning did not appear with the prior version of the library.
 Please help me to understand what changed, and how to fix the change so
the warning no longer appears.
Thanks,
Rich
-- 
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

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