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

Showing 17 results of 17

From: Christopher B. <Chr...@no...> - 2007年06月08日 21:19:14
Sturla Molden wrote:
>> If you use the new matplotlib 0.90.1 version then this has gone away.
> 
> I do, and it hasn't gone away. I used the binary installer for Python 2.5
> on Windows (matplotlib-0.90.1.win32-py2.5.exe).
> 
> When I looked at the code in SVN, the bug was there as well.
That's what I'd expect. in 0.90.0, I think all that was changed was the 
build code, so that the accelerator no longer builds be default.
Sturla Molden wrote:
> _wxagg.pyd has a dependency on a unicode version of a "hybrid" (i.e. 
> debug) wxWidgets library, wxmsw26uh_vc.dll. I verified this using MSVC 
> dumpbin utility. No users of wxPython 2.8 will have this dll installed.
anyone doing a clean install of MPL 0.90 should have _wxagg.pyd either.
> At the bottom of the file backends_wxagg.py, there is an import 
> statement for _wxagg.pyd:
> 
> try:
> import _wxagg
> except ImportError:
> _wxagg = None
> 
> Obviously this import always fails on wxPython 2.8, and is the cause of 
> the redundant error message. _wxagg.pyd is not needed with wxPython 2.8, 
> so the import should not be attempted at all.
That was supposed to be checking whether _wxagg.pyd was there at all. If 
it's there with wxPython2.8, something odd happened -- maybe not that 
odd, it could happen if wxPython were upgraded after MPL was installed, 
but only if it's an old MPL or the accelerator build was turned on on 
purpose, overriding the default. I suspect you installed MPL 0.90 over 
an older version, which causes problems in various errors -- maybe the 
Windows binary installer could do some clean up first?
So the key is this -- the accelerator is deprecated, so this shouldn't 
come up , and a couple versions down the road, we could probably remove 
the attempt to import it.
> Instead, it should read like this:
> 
> if getattr(wx, '__version__', '0.0')[0:3] < '2.8':
> try:
> import _wxagg # C++ accelerator with wxPython 2.6
> except ImportError:
> _wxagg = None # default to pure Python
> else: # wxPython 2.8, no accelerator needed
> _wxagg = None
That would probably work fine, but I'm not sure it's even worth it, 
unless anyone wants to run the accelerator with 2.6 and also have 2.8 
installed, switching between them with wxversion -- a small pool of people!
By the way, why not just:
if wx.__version__[0:3] < '2.8'
or even
wx.__version__ < '2.8'
which is think works fine.
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Sturla M. <st...@mo...> - 2007年06月08日 20:46:40
> Hi Sturla,
> If you use the new matplotlib 0.90.1 version then this has gone away.
I do, and it hasn't gone away. I used the binary installer for Python 2.5
on Windows (matplotlib-0.90.1.win32-py2.5.exe).
When I looked at the code in SVN, the bug was there as well.
S.M.
From: Trevis C. <t_...@mr...> - 2007年06月08日 18:46:29
Thanks!
I'll have to play with this a bit to see if it works for what I want to
do.
> -----Original Message-----
> From: John Hunter [mailto:jd...@gm...]
> Sent: Friday, June 08, 2007 12:41 PM
> To: Trevis Crane
> Cc: mat...@li...
> Subject: Re: [Matplotlib-users] interacting with data plot
>=20
> On 6/8/07, Trevis Crane <t_...@mr...> wrote:
> >
> >
> >
> >
> > Hi all,
> >
> >
> >
> > I have a plot of data that I am enabling the user to interact with.
That
> > is, I want them to be able to pick a point, and then have a new plot
pop up
> > in a different figure showing more info about that point.
>=20
> Here is an example that I just committed to svn as
examples/pick_event_demo2.py
>=20
> It made me realize that despite all my protestations not to repeatedly
> call show, we do not have a backend dependent way to raise new figures
> created in mpl callbacks. Since we've mostly made show bullet-proof
> to repeated calls (because we don't restart the mainloops) this works,
> but we do need a backend independent way to raise figures.
>=20
> One approach would be to have the figure creation function (eg in the
> backend) attach a method show() that raises the figure when called, eg
> fig.show()
>=20
> In any case, here is the example code, also attached in case the lines
> get wrapped
>=20
>=20
> """
> compute the mean and stddev of 100 data sets and plot mean vs stddev.
> When you click on one of the mu, sigma points, plot the raw data from
> the dataset that generated the mean and stddev
> """
> import numpy
> from pylab import figure, show
>=20
>=20
> X =3D numpy.random.rand(100, 1000)
> xs =3D numpy.mean(X, axis=3D1)
> ys =3D numpy.std(X, axis=3D1)
>=20
> fig =3D figure()
> ax =3D fig.add_subplot(111)
> ax.set_title('click on point to plot time series')
> line, =3D ax.plot(xs, ys, 'o', picker=3D5) # 5 points tolerance
>=20
>=20
> def onpick1(event):
>=20
> if event.artist!=3Dline: return True
>=20
> N =3D len(event.ind)
> if not N: return True
>=20
> figi =3D figure()
> for subplotnum, dataind in enumerate(event.ind):
> ax =3D figi.add_subplot(N,1,subplotnum+1)
> ax.plot(X[dataind])
> ax.text(0.05, 0.9, 'mu=3D%1.3f\nsigma=3D%1.3f'%(xs[dataind],
ys[dataind]),
> transform=3Dax.transAxes, va=3D'top')
> ax.set_ylim(-0.5, 1.5)
> ax.figure.canvas.draw()
> print 'plotted'
> show() # oops, we need a way to raise figures created in callbacks
> return True
>=20
> fig.canvas.mpl_connect('pick_event', onpick1)
>=20
> show()
From: Stephan B. <ste...@vi...> - 2007年06月08日 18:31:15
On June 8, 2007, Darren Dale wrote:
> Unfortunately, psfrag produces postscript that can not be embedded in
> another file, so we have to distill the output. By default, the ghostscript
> distiller is used, but if you have pdftops (available with xpdf), you can
> set the ps.usedistiller option to xpdf and the fonts will be embedded. This
> is discussed at http://www.scipy.org/Cookbook/Matplotlib/UsingTex.
You're right; using 'xpdf' solved my problem. I didn't notice the (last) 
sentence which mentions using xpdf and poppler as a backend. Thanks for 
pointing it out.
Stephan
From: John H. <jd...@gm...> - 2007年06月08日 18:13:36
On 6/8/07, John Hunter <jd...@gm...> wrote:
> It made me realize that despite all my protestations not to repeatedly
> call show, we do not have a backend dependent way to raise new figures
> created in mpl callbacks. Since we've mostly made show bullet-proof
> to repeated calls (because we don't restart the mainloops) this works,
> but we do need a backend independent way to raise figures.
I just made a minor modification to the backends (GTK, QT, QT4, Tk,
and WX) in the figure managers to attach a show method to the figure
class. It's not terribly elegant (and using this approach means it
will not show up properly in the class documentation) but it works.
If someone has a better, more elegant approach, I'm all for it, but at
least now you can do
 fig.show()
in pylab and it will do all the necessary GUI calls to raise the
window. I've tested on GTK* and TkAgg -- those of you with svn access
and WX* or QT* should test examples/pick_event_demo2.py on those
platforms.
The downside of this approach is that it makes porting pylab code to
embedded GUI code a little harder, but such is the price of
convenience.
JDH
From: John H. <jd...@gm...> - 2007年06月08日 17:40:46
Attachments: pick_event_demo2.py
On 6/8/07, Trevis Crane <t_...@mr...> wrote:
>
>
>
>
> Hi all,
>
>
>
> I have a plot of data that I am enabling the user to interact with. That
> is, I want them to be able to pick a point, and then have a new plot pop up
> in a different figure showing more info about that point.
Here is an example that I just committed to svn as examples/pick_event_demo2.py
It made me realize that despite all my protestations not to repeatedly
call show, we do not have a backend dependent way to raise new figures
created in mpl callbacks. Since we've mostly made show bullet-proof
to repeated calls (because we don't restart the mainloops) this works,
but we do need a backend independent way to raise figures.
One approach would be to have the figure creation function (eg in the
backend) attach a method show() that raises the figure when called, eg
fig.show()
In any case, here is the example code, also attached in case the lines
get wrapped
"""
compute the mean and stddev of 100 data sets and plot mean vs stddev.
When you click on one of the mu, sigma points, plot the raw data from
the dataset that generated the mean and stddev
"""
import numpy
from pylab import figure, show
X = numpy.random.rand(100, 1000)
xs = numpy.mean(X, axis=1)
ys = numpy.std(X, axis=1)
fig = figure()
ax = fig.add_subplot(111)
ax.set_title('click on point to plot time series')
line, = ax.plot(xs, ys, 'o', picker=5) # 5 points tolerance
def onpick1(event):
 if event.artist!=line: return True
 N = len(event.ind)
 if not N: return True
 figi = figure()
 for subplotnum, dataind in enumerate(event.ind):
 ax = figi.add_subplot(N,1,subplotnum+1)
 ax.plot(X[dataind])
 ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
 transform=ax.transAxes, va='top')
 ax.set_ylim(-0.5, 1.5)
 ax.figure.canvas.draw()
 print 'plotted'
 show() # oops, we need a way to raise figures created in callbacks
 return True
fig.canvas.mpl_connect('pick_event', onpick1)
show()
From: Werner F. B. <wer...@fr...> - 2007年06月08日 15:43:12
Hi Sturla,
Sturla Molden wrote:
> There is an annoying bug when using wxAgg backend with wxPython 2.8 on 
> Windows. Whenever matplotlib is imported, we get a modal message box 
> displaying the error message:
>
> "This application has failed to start because wxmsw26uh_vc.dll was not 
> found. Reinstalling the application may fix this problem."
>
> After clicking OK, everything works fine.
>
>
> Here is a bugfix:
> 
If you use the new matplotlib 0.90.1 version then this has gone away.
Werner
Hi Andrew,
Andrew Straw wrote:
> ...
> Dear Werner,
>
> I am reluctant to eliminate the sub-folder structure because I think 
> it would add the possibility of unnecessary bugs to just the py2exe 
> built version. Would it be possible for you to re-factor this to 
> include the directory layout? When you test it, can you test some 
> interactive plot to make sure all the button icons are loaded properly?
I don't know how to change "matplotlib.get_py2exe_datafiles()" to retain 
the folder structure. But in the attached setup.py I used 
"matplotlib.get_data_path()" for each of the sub-folders and then define 
the folder structure again in the py2exe "data_files" section. The 
enclosed setup.py builds an exe for embedding_in_wx.py and I have no 
problems running it and the toolbar shows all its icons.
I am also enclosing some example files which I have upgraded to the new 
wxPython namespace - I had sent them some time ago but the examples.zip 
file I just downloaded contains the old versions.
dynamic_demo_wx.py, namespace changes and a OnClose event to stop the 
timer (otherwise the script can not be stopped by clicking on the X).
dynamic_image_wxagg.py, namespace changes
dynamic_image_wxagg2.py, namespace changes and removed numarray stuff.
embedding_in_wx.py, namespace changes
embedding_in_wx2.py, namespace changes
embedding_in_wx4.py, namespace changes
Can you update the zip file with the above files?
Best regards
Werner
From: Jeff W. <js...@fa...> - 2007年06月08日 15:35:38
nappie74 wrote:
> Hi,
> I'm new in matplolib code,
> I have matrix of winds vectors derivated from quiver introducing U,V
> components,and positioning these in a sorted grid X,Y
> with the command quiver (x, y, u, v,color='r')
> It's possible to put in the figure the barbs to every arrow vector or
> scaling the arrow with the values of its lenght derived by >>> r =
> sqrt((U**2)+(V**2))
> Thanks a lot to averyone give me help
> 
>> ----(^_^)----<
>> 
>
> Pie
> 
Pie: quiver scales the vectors automatically, based upon their 
magnitude. See the docs at
http://matplotlib.sourceforge.net/matplotlib.pylab.html#-quiver
See in particular the 'scale' and 'units' keywords. The 'quiver_demo.py' might help too.
If you're asking about wind barbs (http://www.rap.ucar.edu/weather/info/about_windbarb.html), there isn't currently a built-in facility for that in matplotlib. 
-Jeff
 
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: Trevis C. <t_...@mr...> - 2007年06月08日 14:58:04
Hi all,
=20
I have a plot of data that I am enabling the user to interact with.
That is, I want them to be able to pick a point, and then have a new
plot pop up in a different figure showing more info about that point.
=20
So, looking through the manual and the tutorial I have taken the code
from one of the examples and am trying to modify it to work for my
needs. Here's what I have so far:
=20
field =3D arrange(-1,1.25,0.25)
CA =3D cellArray() # this is an object defined elsewhere.
Ij =3D # a list of 2d arrays of data
=20
def state_picker(line, mouseevent):
 if mouseevent.xdata is None:=20
 return False, dict()
 xdata =3D line.get_xdata()
 ydata =3D line.get_ydata()
 maxd =3D 0.1
 d =3D nx.sqrt((xdata - mouseevent.xdata)**2. + (ydata -
mouseevent.ydata)**2.)
 =20
 ind =3D nx.nonzero(nx.less_equal(d, maxd))
 if len(ind):
 out =3D dict(ind=3Dind)
 return True, out
 else:
 return False, dict()
=20
def onpick2(event,cellArray,Ij):
 Ij =3D Ij[event.ind] # chose the list element from Ij
corresponds to the point selected by the user
 cellArray.plot('flux',inputIj=3DIj) # the cellArray object =
has
its own plot method that requires these two arguments
 =20
fig =3D figure()
ax1 =3D fig.add_subplot(111)
ax1.set_title('Energy States vs. Applied Flux per cell')
for i in range(len(field)):
 # energy is a list of arrays of different length=20
 ax1.plot(field[i]*ones(len(energy[i])),energy[i],'.b',
picker =3D state_picker)
ax1.set_xlim(-1.1,1.1)
ax1.set_xlabel('Applied Flux per cell')
ax1.set_ylabel('Array Energy (Ej)')
fig.canvas.mpl_connect('pick_event', onpick2)
show()
=20
=20
=20
The problem I'm having is that I can't seem to pass extra arguments to
either state_picker or onpick2. Can I?
=20
thanks for your help,
trevis
=20
________________________________________________
=20
Trevis Crane
Postdoctoral Research Assoc.
Department of Physics
University of Ilinois
1110 W. Green St.
Urbana, IL 61801
=20
p: 217-244-8652
f: 217-244-2278
e: tc...@ui...
________________________________________________
=20
From: John H. <jd...@gm...> - 2007年06月08日 14:50:38
Attachments: plotfile.png
On 6/8/07, Lionel Roubeyrie <lro...@li...> wrote:
> Hi John,
> very very interesting idea.
> Is there a way to add some extras informations on the records arrays columns,
> like the units or/and the desired labels for the resulting plotted lines,
> directly retrieved in the CSV files?
It could be done, but my goal here is not to create a persistence
layer for record arrays, or a method of describing them or mpl labels,
but rather a way to easily import 3rd party CSV files into numpy
record arrays. I work with a lot of tab/space/ascii delimited files,
and found myself duplicating a lot of code importing them into record
arrays. This function is the distillation of that code. It would be
fairly easy to add designated rows for those who did want to decorate
their CSV files. I think it might be most useful to support a row
that provided a numpy dtype per column, or perhaps the name of a
converter function...
One thing people coming from gnuplot miss is file plotting
functionality. I just added a function to pylab called plotfile which
uses the csv2rec functionality (with autolabeling etc) to plot data
from a file. Eg,
>>> plotfile(fname, (0,5,6))
plots columns 5 and 6 against column 0. And
>>> plotfile(fname, ('date', 'volume', 'adj_close'),
plotfuncs={'volume': 'bar'})
does the same using the names of the columns, using "plot" for
adj_close (the default) and "bar" for volume (customization from the
plotfuncs dictionary). The column names in either case are used to
create default x and y labels.
The 2nd command produces the attached plot. This is just a first
pass, so if people want to see a different interface or have an
opinion what should be returned, or where this function should live
outside of pylab, feel free to comment or commit changes.
JDH
From: Sturla M. <st...@mo...> - 2007年06月08日 14:27:53
There is an annoying bug when using wxAgg backend with wxPython 2.8 on 
Windows. Whenever matplotlib is imported, we get a modal message box 
displaying the error message:
"This application has failed to start because wxmsw26uh_vc.dll was not 
found. Reinstalling the application may fix this problem."
After clicking OK, everything works fine.
Here is a bugfix:
_wxagg.pyd has a dependency on a unicode version of a "hybrid" (i.e. 
debug) wxWidgets library, wxmsw26uh_vc.dll. I verified this using MSVC 
dumpbin utility. No users of wxPython 2.8 will have this dll installed.
At the bottom of the file backends_wxagg.py, there is an import 
statement for _wxagg.pyd:
try:
 import _wxagg
except ImportError:
 _wxagg = None
Obviously this import always fails on wxPython 2.8, and is the cause of 
the redundant error message. _wxagg.pyd is not needed with wxPython 2.8, 
so the import should not be attempted at all. Python will trap the 
ImportError exception, but a redundant error message is displayed.
Instead, it should read like this:
if getattr(wx, '__version__', '0.0')[0:3] < '2.8':
 try:
 import _wxagg # C++ accelerator with wxPython 2.6
 except ImportError:
 _wxagg = None # default to pure Python
else: # wxPython 2.8, no accelerator needed
 _wxagg = None
On wxPython 2.6, the C++ accelerator in _wxagg.pyd will not be used 
unless _wxagg.pyd is linked against the xwWidgets library actually 
present, and Python will default to Python code instead. Fixing these 
issues on wxpython 2.6 thus require a rebuild of _wxagg.pyd that links 
it with the wx library present on the system.
If all you need is to get rid of the error message, just comment out the 
import statement and set the global variable _wxagg to None.
Regards,
Sturla Molden
From: nappie74 <nap...@ti...> - 2007年06月08日 13:15:25
Hi,
I'm new in matplolib code,
I have matrix of winds vectors derivated from quiver introducing U,V
components,and positioning these in a sorted grid X,Y
with the command quiver (x, y, u, v,color='r')
It's possible to put in the figure the barbs to every arrow vector or
scaling the arrow with the values of its lenght derived by >>> r =
sqrt((U**2)+(V**2))
Thanks a lot to averyone give me help
>----(^_^)----<
Pie
-- 
View this message in context: http://www.nabble.com/to-build-barbs-in-quiver-resultant-vector-tf3889736.html#a11026235
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Darren D. <dd...@co...> - 2007年06月08日 11:45:06
On Thursday 07 June 2007 10:06:03 pm Stephan Bourduas wrote:
> Hello,
>
> I've been using Matplotlib to generate postscript (eps) graphics which I
> import into my latex documents. I tried using Latex to typeset
> mathematical symbols on my plots using the steps described here:
>
> http://www.scipy.org/Cookbook/Matplotlib/UsingTex
>
> The problem (I think) is that the eps files are genrated using dvipng,
> which results in ugly figures in the final PDF output. Is there a way to
> get Matplotlib to *not* use dvipng as the backend?
matplotlib only uses dvipng to render the text on screen in the plot window. 
Postscript file generation does not use dvipng. We paste in some tags and use 
the latex package psfrag to replace the tags with the text.
> On the other hand, if I
> uncomment the "rc('text', usetex=True)" line in the script so that Latex is
> used for the fonts, I get the following when converting the resulting EPS
> file to PDF:
>
> =======================
> $ ps2pdf test.eps
> $ pdffonts test.pdf
> name type emb sub uni object ID
> ------------------------------------ ------------ --- --- --- ---------
>
> =======================
>
> As you can see, there's no font embedding in this case and the image looks
> bad when previewed in either Ghotsview (eps) or in PDF. Does anyone know
> if it's possible to get Matplotlib + Latex font embedding to work?
Unfortunately, psfrag produces postscript that can not be embedded in another 
file, so we have to distill the output. By default, the ghostscript distiller 
is used, but if you have pdftops (available with xpdf), you can set the 
ps.usedistiller option to xpdf and the fonts will be embedded. This is 
discussed at http://www.scipy.org/Cookbook/Matplotlib/UsingTex.
Darren
-- 
Darren S. Dale, Ph.D.
dd...@co...
From: Mark B. <ma...@gm...> - 2007年06月08日 09:22:19
I know for a fact that it used to work for fill( [0,1,1], [0,0,1],
'#FFFF66').
But maybe I was just lucky.
It would be nice if you can make the change officially,
Mark
On 6/7/07, Eric Firing <ef...@ha...> wrote:
>
> Mark Bakker wrote:
> > Hello -
> >
> > This used to work:
> > fill( [0,1,1], [0,0,1], '#FFFF66')
> >
> > But it doesn't work anymore under 0.90.1.
> > I thought it still worked under 0.90.0
>
> I don't think this behavior is documented, and a very quick look at
> recent changes to axes.py did not reveal a corresponding change, but it
> looks like it would be easy add and it seems to me like a useful and
> logical extension. The idea is that if a string is a valid mpl
> colorspec (including, but not limited to, hex strings as in the example
> above), then it sets the color; otherwise the present code is used to
> interpret strings like '-k' etc.
>
> If no one is working on this, and if there is no objection, I can
> implement it later today or tomorrow. Does anyone see any ambiguity or
> other problem with this?
>
> Eric
>
> >
> > Anybody see the same problem?
> > Plot seems to have the same problem:
> > plot([1,2,3],'#afeeee')
> >
> > Error message for the plot statement:
> > Traceback (most recent call last):
> > File "<pyshell#11>", line 1, in ?
> > plot([1,2,3],'#afeeee')
> > File "C:\Python24\Lib\site-packages\matplotlib\pylab.py", line 2028,
> > in plot
> > ret = gca().plot(*args, **kwargs)
> > File "C:\Python24\Lib\site-packages\matplotlib\axes.py", line 2535, in
> > plot
> > for line in self._get_lines(*args, **kwargs):
> > File "C:\Python24\Lib\site-packages\matplotlib\axes.py", line 421, in
> > _grab_next_args
> > for seg in self._plot_2_args(remaining, **kwargs):
> > File "C:\Python24\Lib\site-packages\matplotlib\axes.py", line 313, in
> > _plot_2_args
> > linestyle, marker, color = _process_plot_format(fmt)
> > File "C:\Python24\Lib\site-packages\matplotlib\axes.py", line 153, in
> > _process_plot_format
> > raise ValueError, err
> > ValueError: Unrecognized character # in format string
> >
> > Thanks, Mark
> >
> >
> > ------------------------------------------------------------------------
> >
> >
> -------------------------------------------------------------------------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Lionel R. <lro...@li...> - 2007年06月08日 07:08:19
Hi John,
very very interesting idea.
Is there a way to add some extras informations on the records arrays column=
s,=20
like the units or/and the desired labels for the resulting plotted lines,=20
directly retrieved in the CSV files?
Cordialy
Le jeudi 07 juin 2007, John Hunter a =E9crit=A0:
> I just added support for native plotting of python date and datetime
> objects (you still can, but don't have to use plot_date with date2num
> conversions). We will continue to do conversion to floats under the
> hood, but the conversion can be handled automagically. I also added
> support for loading CSV files (or general space/tab/comma delimited
> files) into numpy record arrays, and the type conversions (int, float,
> date, etc...) happen automagically. The function assumes there is a
> header row, and these strings will be munged to give valid python
> attribute names. It inspects the first checkrows lines after the
> header to try and infer the datatype and set the appropriate
> conversion function. It's not entirely bullet proof, but it should
> cover a lot of common use cases.
>
> Here is an example (svn only)
>
> from matplotlib.mlab import csv2rec
> from pylab import figure, show
>
> a =3D csv2rec('data/msft.csv')
> fig =3D figure()
> ax =3D fig.add_subplot(111)
> ax.plot(a.date, a.adj_close, '-')
> fig.autofmt_xdate()
> show()
>
> The autofmt_xdate is optional, but is a new function that does a few
> things you usually want in date plots: turns off tick labels in the
> upper subplots if any, rotates the tick labels on the lowest axes and
> right aligns them, and increases the bottom of the subplots adjust to
> make room for the rotated tick labels.
>
> Here is what the dtype looks like from the example above.
>
> In [3]: !head -3 data/msft.csv
> Date,Open,High,Low,Close,Volume,Adj. Close*
> 19-Sep-03,29.76,29.97,29.52,29.96,92433800,29.79
> 18-Sep-03,28.49,29.51,28.42,29.50,67268096,29.34
>
> In [4]: a =3D csv2rec('data/msft.csv')
>
> In [5]: a.dtype
> Out[5]: dtype([('date', '|O4'), ('open', '<f8'), ('high', '<f8'),
> ('low', '<f8'), ('close', '<f8'), ('volume', '<i4'), ('adj_close',
> '<f8')])
>
> In [6]: a.date[:2]
> Out[6]: array([2003年09月19日 00:00:00, 2003年09月18日 00:00:00], dtype=3Dobjec=
t)
>
> I'll probably add a few performance features to the csv2rec function,
> mainly to let you skip columns and supply conversion functions where
> desired because the autodate parser is pretty slow if you want to
> parse date strings, but this is enough to make it useful. Another
> useful feature will be able to support customizable type dependent
> NULL value conversion (eg convert to numpy.nan for floats,
> '0000-00-00' for dates, etc...)
>
> Record arrays are your friend; have fun!
> JDH
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
=2D-=20
Lionel Roubeyrie - lro...@li...
Chag=E9 d'=E9tudes et de maintenance
LIMAIR - la Surveillance de l'Air en Limousin
http://www.limair.asso.fr
From: Stephan B. <ste...@vi...> - 2007年06月08日 02:06:09
Hello,
I've been using Matplotlib to generate postscript (eps) graphics which I 
import into my latex documents. I tried using Latex to typeset mathematical 
symbols on my plots using the steps described here:
http://www.scipy.org/Cookbook/Matplotlib/UsingTex
The problem (I think) is that the eps files are genrated using dvipng, which 
results in ugly figures in the final PDF output. Is there a way to get 
Matplotlib to *not* use dvipng as the backend? 
For example. If I use the following simple script to generate a eps file
=========================================
from matplotlib import rc
import pylab
from pylab import *
import numarray as na
params = {
 'backend': 'ps',
 'axes.titlesize': 24,
 'axes.labelsize': 18,
 'xtick.labelsize': 14,
 'ytick.labelsize': 14,
 'legend.fontsize': 14
 }
pylab.rcParams.update(params)
#rc('text', usetex=True)
N = 4
ind = arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
data01 = (5, 10, 3, 2)
data02 = (3, 7, 10, 6)
title('Normal EPS Generation')
p1 = bar(ind, data01, width, color='#CCCCFF')
p2 = bar(ind+width, data02, width, color='#3399FF')
xticks(ind+width, ('1', '2', '3', '4') )
xlim(-width,len(ind))
legend( (p1[0], p2[0]), ('data01', 'data02'), loc='upper right', shadow=False)
pylab.savefig('test.eps')
=============================================
I get a nice EPS file which looks good in my final PDF. Also, running ps2pdf 
and pdffonts shows that all the fonts are properly embedded in the eps file:
======================
$ ps2pdf test.eps
$ pdffonts test.pdf
name type emb sub uni object ID
------------------------------------ ------------ --- --- --- ---------
NBOBDW+BitstreamVeraSans-Roman TrueType yes yes no 8 0
=======================
So as one would expect, the plots look good in the final PDF when zooming in 
and out because all the fonts are there. On the other hand, if I uncomment 
the "rc('text', usetex=True)" line in the script so that Latex is used for 
the fonts, I get the following when converting the resulting EPS file to PDF:
=======================
$ ps2pdf test.eps
$ pdffonts test.pdf
name type emb sub uni object ID
------------------------------------ ------------ --- --- --- ---------
=======================
As you can see, there's no font embedding in this case and the image looks bad 
when previewed in either Ghotsview (eps) or in PDF. Does anyone know if it's 
possible to get Matplotlib + Latex font embedding to work?
Regards,
Stephan

Showing 17 results of 17

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