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



Showing 9 results of 9

From: Mark B. <ma...@gm...> - 2005年08月05日 17:00:17
I like the new file dialog that Clovis suggested for the Tk backend.
I suggest two modifications before submitting a patch:
1. Could you add an error message when an unknown extension is given?
Right now it does nothing, but the user should probably be warned.
2. Could you add a warning when an existing filename is given and ask if th=
e=20
user wants to overwrite?
When that is added, I suggest you submit a patch.
Thanks
Mark
Message: 1
Date: 2005年8月04日 11:19:50 -0300
From: Clovis Goldemberg <cl...@pe...>
To: mat...@li...urcef=20
>=20
> orge.net <http://orge.net>
> Subject: [Matplotlib-users] Question about toolbar customization
>=20
> Dear all,
>=20
> I have two suggestions about toolbar customization:
>=20
> 1. In the 'matplotlibrc' file the toolbar line should be changed in
> order to include a "custom toolbar"
>=20
> toolbar : toolbar2 # None | classic | toolbar2 | custom
>=20
> 2. In the 'backend_tkagg.py file', inside the 'NavigationToolbar2TkAgg
> class' the
> save_figure procedure should be changed to somewhat:
>=20
> def save_figure(self):
> from tkFileDialog import asksaveasfilename
> fname =3D asksaveasfilename(master=3Dself.window,
> title=3D'Save the figure',
> filetypes=3D[('Encapsulated Postscript
> File','*.eps'),
> ('Scalable Vector
> Graphics','*.svg'),
> ('Portable Network
> Graphics','*.png')])
> # initialfile=3DInitialFilename)
> if fname =3D=3D "" :
> return
> else:
> bname, fext =3D os.path.splitext(fname)
> if (fext.lower()=3D=3D'.png'):
> self.canvas.print_figure(fname, dpi=3D300)
> elif (fext.lower()=3D=3D'.eps'):
> self.canvas.print_figure(fname)
> elif (fext.lower()=3D=3D'.svg'):
> self.canvas.print_figure(fname)
>=20
> I think that the asksaveasfilename function provided by
> tkFileDialog is "better"
From: John H. <jdh...@ac...> - 2005年08月05日 15:33:11
>>>>> "Mark" == Mark Bakker <ma...@gm...> writes:
 Mark> Hello'all - I am trying to develop my own toolbar and
 Mark> thought the easiest way to do this was to define a new
 Mark> backend and change it in that file. Matplotlib includes the
 Mark> 'template' backend as a start. To get going, I copied the
 Mark> entire TkAgg backend into the template backend and set the
 Mark> backend to 'Template' in the matplotlibrc file. But now
 Mark> when I run pylab, it doesn't work interactivly anymore.
 Mark> When I just give a plot([1,2,3]), it draws the figure window
 Mark> but not the figure. draw_if_interactive() doesn't work
 Mark> either, even though interactive is set to True. draw() does
 Mark> work and creates the correct figure. Is Tk special ? I
 Mark> thought this should work.
I'm not sure why this didn't work. You might simply copy
backend_tkagg to backend_tkagg2, edit matplotlib/backends/__init__.py
and add TkAgg2 to the interactive_bk list there, and reinstall.
Alternatively, you could follow the examples of embedding_in_tk*.py
and create your own tkapp with your own toolbar. 
We've discussed ways of customizing the toolbar before, but haven't
gotten anything working yet. 
JDH
From: Tom L. <lo...@as...> - 2005年08月05日 14:31:08
Hi John-
> Go to line 455 on matplotlib/font_manager.py
> and uncomment the except part so that it reads...
Worked like a charm! Thanks so much for the quick reply.
> Tom> After this, further attempts to import or reload pylab give
> Tom> no errors, but there is no pylab.plot (or any other pylab
> Tom> function I've tried).
> 
> I'm not sure what this is about....
I probably wasn't clear enough in the original post---this was
true only in the same python process that attempted the import
in the first place (i.e., after the failure, I didn't quit
python, but just tried 'import pylab' and 'reload(pylab)').
I suspect it has to do with how pylab appears to be doing
a kind of "lazy import." In any case, all appears well now,
including the TeX support. Very nice!
-Tom
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
From: John H. <jdh...@ac...> - 2005年08月05日 14:15:51
> Hello,
> 
> I want to plot some digital signals using matplotlib. 
> I want to plot some 6 digital signals (or say any arbitary number of
> signals) in one figure.
> For each signal I want a y-label displayed.
> 
> One way to plot digital signals in one plot is that I add an offset to
> other signals and then plot. But I thought if anyone knows a better
> idea then it will be good.
> Also how can I have different y-labels for each signal. I don't want
> to use legends because with too many signals it will be dificult to
> match the legend with where the signal is.
> 
> I am attaching a picture which is generated by some other tools but
> now I want to genrate somewhat similar way in matplotlib.
> Can anyone give me some small hints?
There are a few ways to do it. You could make each signal a separate
axes and make the y label horizontal. This works fine for a small
number of signals (4-10 say) except the extra horizontal lines and
ticks around the axes may be annoying. It's on our list of things to
change the way these axes lines are draw, but it isn't done yet.
 from pylab import figure, show, setp
 from matplotlib.numerix import sin, cos, exp, pi, arange
 yprops = dict(rotation=0,
 horizontalalignment='right',
 verticalalignment='center')
 axprops = dict(yticks=[])
 fig = figure()
 t = arange(0.0, 2.0, 0.01)
 ax1 =fig.add_axes([0.1, 0.7, 0.8, 0.2], **axprops)
 ax1.plot(t, sin(2*pi*t))
 ax1.set_ylabel('S1', **yprops)
 # force x axes to remain in register, even with toolbar navigation
 ax2 = fig.add_axes([0.1, 0.5, 0.8, 0.2], sharex=ax1, **axprops)
 ax2.plot(t, exp(-t))
 ax2.set_ylabel('S2', **yprops)
 ax3 = fig.add_axes([0.1, 0.3, 0.8, 0.2], sharex=ax1, **axprops)
 ax3.plot(t, sin(2*pi*t)*exp(-t))
 ax3.set_ylabel('S3', **yprops)
 ax4 = fig.add_axes([0.1, 0.1, 0.8, 0.2], sharex=ax1, **axprops)
 ax4.plot(t, sin(2*pi*t)*cos(4*pi*t))
 ax4.set_ylabel('S4', **yprops)
 show()
It turns out that I lot signals in the way you suggest all the time
(EEG viewer), see a screenshot of the application that gave birth to
matplotlib at
http://matplotlib.sourceforge.net/screenshots/eeg_small.png . I've
been meaning to refactor the EEG viewer into a "multiline" viewer and
put it into matplotlib but haven't gotten around to it (the source
code is at http://pbrain.sf.net). 
Here is an example of how I do it in my app with additional comments.
Note that this will break the y behavior of the toolbar because we
have changed all the default transforms. In my application I have a
custom toolbar to increase or decrease the y scale. In this example,
I bind the plus/minus keys to a function which increases or decreases
the y gain. Perhaps I will take this and wrap it up into a function
called plot_signals or something like that because the code is a bit
hairy since it makes heavy use of the somewhat arcane matplotlib
transforms. I suggest reading the header of
http://matplotlib.sourceforge.net/matplotlib.transforms.html before
trying to understand this example.
from pylab import figure, show, setp, connect, draw
from matplotlib.numerix import sin, cos, exp, pi, arange
from matplotlib.numerix.mlab import mean
from matplotlib.transforms import Bbox, Value, Point, \
 get_bbox_transform, unit_bbox
# load the data
t = arange(0.0, 2.0, 0.01)
s1 = sin(2*pi*t)
s2 = exp(-t)
s3 = sin(2*pi*t)*exp(-t)
s4 = sin(2*pi*t)*cos(4*pi*t)
s5 = s1*s2
s6 = s1-s4
s7 = s3*s4-s1
signals = s1, s2, s3, s4, s5, s6, s7
for sig in signals:
 sig = sig-mean(sig)
 
lineprops = dict(linewidth=1, color='black', linestyle='-')
fig = figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
# The normal matplotlib transformation is the view lim bounding box
# (ax.viewLim) to the axes bounding box (ax.bbox). Where are going to
# define a new transform by defining a new input bounding box. See the
# matplotlib.transforms module helkp for more information on
# transforms
# This bounding reuses the x data of the viewLim for the xscale -10 to
# 10 on the y scale. -10 to 10 means that a signal with a min/max
# amplitude of 10 will span the entire vertical extent of the axes
scale = 10
boxin = Bbox(
 Point(ax.viewLim.ll().x(), Value(-scale)),
 Point(ax.viewLim.ur().x(), Value(scale)))
# height is a lazy value
height = ax.bbox.ur().y() - ax.bbox.ll().y()
boxout = Bbox(
 Point(ax.bbox.ll().x(), Value(-0.5) * height),
 Point(ax.bbox.ur().x(), Value( 0.5) * height))
# matplotlib transforms can accepts an offset, which is defined as a
# point and another transform to map that point to display. This
# transform maps x as identity and maps the 0-1 y interval to the
# vertical extent of the yaxis. This will be used to offset the lines
# and ticks vertically
transOffset = get_bbox_transform(
 unit_bbox(),
 Bbox( Point( Value(0), ax.bbox.ll().y()),
 Point( Value(1), ax.bbox.ur().y())
 ))
# now add the signals, set the transform, and set the offset of each
# line
ticklocs = []
for i, s in enumerate(signals):
 trans = get_bbox_transform(boxin, boxout) 
 offset = (i+1.)/(len(signals)+1.)
 trans.set_offset( (0, offset), transOffset)
 ax.plot(t, s, transform=trans, **lineprops)
 ticklocs.append(offset)
ax.set_yticks(ticklocs)
ax.set_yticklabels(['S%d'%(i+1) for i in range(len(signals))])
# place all the y tick attributes in axes coords 
all = []
labels = []
ax.set_yticks(ticklocs)
for tick in ax.yaxis.get_major_ticks():
 all.extend(( tick.label1, tick.label2, tick.tick1line,
 tick.tick2line, tick.gridline))
 labels.append(tick.label1)
 
setp(all, transform=ax.transAxes)
setp(labels, x=-0.01)
ax.set_xlabel('time (s)')
# Because we have hacked the transforms, you need a special method to
# set the voltage gain; this is a naive implementation of how you
# might want to do this in real life (eg make the scale changes
# exponential ranther than linear) but it gives you the idea
def set_ygain(direction):
 set_ygain.scale += direction
 if set_ygain.scale <=0:
 set_ygain.scale -= direction
 return
 for line in ax.lines:
 trans = line.get_transform()
 box1 = trans.get_bbox1()
 box1.intervaly().set_bounds(-set_ygain.scale, set_ygain.scale)
 draw()
set_ygain.scale = scale 
 
def keypress(event):
 if event.key in ('+', '='): set_ygain(-1)
 elif event.key in ('-', '_'): set_ygain(1)
connect('key_press_event', keypress)
ax.set_title('Use + / - to change y gain') 
show()
> Also one more point is if I want all the signal colors in plot to be
> same say black then how can I do it?. The default plot function varies
> the colors of the signal plotted.
pass the color='black' argument to plot
 plot(x, y, color='black')
For marker plots, you may also want to set the markerfacecolor and
markeredgecolor attributes.
From: Robert K. <rk...@uc...> - 2005年08月05日 13:16:10
Tom Loredo wrote:
> After this, further attempts to import or reload pylab give no errors,
> but there is no pylab.plot (or any other pylab function I've tried).
If some kind of error happens while importing a module, then the 
incomplete module object will still exist in sys.modules, so reimporting 
will pick up this object instead of running the code again. If something 
like this happens to you again, try using
 reload(sys.modules['modulename'])
 import modulename
-- 
Robert Kern
rk...@uc...
"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
 -- Richard Harter
From: John H. <jdh...@ac...> - 2005年08月05日 13:09:21
>>>>> "Tom" == Tom Loredo <lo...@as...> writes:
 Tom> Hi folks,
 Tom> I've been using 0.80 on OS X (10.3.9) for a while with no
 Tom> problems (installed from source). I thought I'd take the
 Tom> plunge and install the latest version (again from source),
 Tom> the first time I'm trying it on the Mac with mpl's TeX
 Tom> capability. I am (still) using Apple's Python 2.3.0.
 ....snip...
 Tom> The font in question is a PostScript Type 1 font installed by
 Tom> a music app I use (Finale). There is also an accompanying
 Tom> JazzCord.suit font suitcase. Whether these fonts are in a
 Tom> readable format or not, I would guess that mpl should be able
 Tom> to skip any font files it can't load/identify and proceed
 Tom> with what it *can* load, rather than completely aborting. Or
 Tom> perhaps this is just a symptom of another installation issue.
 Tom> Any ideas on how to proceed? Or do I just go back to 0.80?
 Tom> 8-(
Oops. I was debugging a font problem and commented out the
try/except part of the font manager so I could read the traceback, and
forgot to restore it. Go to line 455 on matplotlib/font_manager.py
and uncomment the except part so that it reads
 try:
 font = ft2font.FT2Font(str(fpath))
 except RuntimeError:
 warnings.warn("Could not open font file %s"%fpath)
 continue
Then remove ~/.matplotlib/ttffont.cache before running again.
 Tom> After this, further attempts to import or reload pylab give
 Tom> no errors, but there is no pylab.plot (or any other pylab
 Tom> function I've tried).
I'm not sure what this is about. Make sure you are running the
backend you think you are by running with --verbose-helpful. As
detailed in the CHANGELOG, the config file organization was recently
changed -- the matplotlibrc file now resides in ~/.matplotlib.
JDH
From: Alex R. <ale...@ya...> - 2005年08月05日 10:35:45
Hi all,
changing from 0.82 to 0.83 and using latex fonts, the "0" label 
disappeared from ticks! maybe I'm wrong in something, but using the 
command "yticks([0.,0.2,etc...])" the problem remains.
Alex.
From: steve s. <el...@gm...> - 2005年08月05日 10:08:11
Hi
I just installed mpl 0.83.2 on a Debian box, kernel 2.4.7, ipython 
0.6.13, GTKAgg backend
ipython - pylab works, but when I try to plot i get
#############################################################################
In [1]: plot([1,2,3])
---------------------------------------------------------------------------
exceptions.SystemError Traceback (most 
recent call last)
SystemError: ../Objects/moduleobject.c:48: bad argument to internal function
Speicherzugriffsfehler
elcorto@bach:~/Install/Matplotlib/matplotlib-0.83.2$
#############################################################################
What can cause this?
cheers,
steve
From: Tom L. <lo...@as...> - 2005年08月05日 04:59:52
Hi folks,
I've been using 0.80 on OS X (10.3.9) for a while with no problems
(installed from source). I thought I'd take the plunge and install the 
latest version (again from source), the
first time I'm trying it on the Mac with mpl's TeX capability. I am
(still) using Apple's Python 2.3.0.
The installation appeared to go fine, but I cannot import pylab:
>>> import pylab
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
 File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/pylab.py", line 1, in ?
 from matplotlib.pylab import *
 File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/matplotlib/pylab.py", 
line 198, in ?
 from axes import Axes, PolarAxes
 File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/matplotlib/axes.py", 
line 14, in ?
 from axis import XAxis, YAxis
 File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/matplotlib/axis.py", 
line 25, in ?
 from font_manager import FontProperties
 File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/matplotlib/
font_manager.py", line 993, in ?
 fontManager = FontManager()
 File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/matplotlib/
font_manager.py", line 837, in __init__
 rebuild()
 File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/matplotlib/
font_manager.py", line 830, in rebuild
 self.ttfdict = createFontDict(self.ttffiles)
 File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/matplotlib/
font_manager.py", line 456, in createFontDict
 font = ft2font.FT2Font(str(fpath))
RuntimeError: Could not load facefile /Library/Fonts/JazzCor; Unknown_File_Format
After this, further attempts to import or reload pylab give no errors,
but there is no pylab.plot (or any other pylab function I've tried).
The font in question is a PostScript Type 1 font installed by a music
app I use (Finale). There is also an accompanying JazzCord.suit font
suitcase. Whether these fonts are in a readable format or not, I 
would guess that mpl should be able to skip any font files it can't
load/identify and proceed with what it *can* load, rather than
completely aborting. Or perhaps this is just a symptom of another
installation issue. Any ideas on how to proceed? Or do I just
go back to 0.80? 8-(
Thanks,
Tom
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
1 message has been excluded from this view by a project administrator.

Showing 9 results of 9

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