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





Showing 22 results of 22

From: John K. <jki...@an...> - 2008年06月25日 22:21:23
Is there a way to find all the "axes" objects or "line" object handles in
pylab? In matlab I used to do something like
A = findobj(gcf)
Allaxes = findall(a,'Type','axes')
Set(allaxes,'Fontname','Arial')
Is there a way to do that in pylab/matplotlib?
Thanks,
j
-----------------------------------
John Kitchin
Assistant Professor
NETL-IAES Resident Institute Fellow
Doherty Hall 3112
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu
From: John H. <jd...@gm...> - 2008年06月25日 22:12:33
On Wed, Jun 25, 2008 at 2:57 PM, Michael Hearne <mh...@us...> wrote:
> It's been a couple of weeks, but I was finally able to chase down what I
> think is causing the problem. I wasn't able to create a standalone script
> that replicates the problem, as my application is very dependent on large
> data sets, but I was able to create two versions of the postscript with
> _almost_ identical input.
>...
> FYI, I know that single quotes in text strings do not _always_ cause an
> error - this is easy to test with basic matplotlib text() calls. All I can
> say is that _sometimes_ it causes problems.
Michael fixed a single quote bug in svn a while back. What version of
mpl are you using? The latest source release at
http://sourceforge.net/project/showfiles.php?group_id=80706 includes
this fix (as does svn).
r5134 | mdboom | 2008年05月09日 08:39:25 -0400 (2008年5月09日) | 2 lines
Fix /singlequote (') in Ps backend.
From: John H. <jd...@gm...> - 2008年06月25日 22:07:46
On Wed, Jun 25, 2008 at 5:01 PM, Michael Hearne <mh...@us...> wrote:
> I'm trying to install matplotlib on a RHEL5 system, and I'm getting errors
> in src/ft2font.h and ft2font.cpp.
>
> An error log from the build command is attached.
>
> I would use an RPM for this platform if I were sure that it would be
> installed in /usr/local/lib... Is there a way to control where RPM's get
> installed?
Make sure you have pkg-config and freetype2-devel installed (don't
know the exact rpm name, could also be freetype-devel). You error
message suggests either you don't have the development headers for
freetype installed, and/or pkg-config cannot find them.
Take a look at the "compiling" and "RPMS" sections of
http://matplotlib.sourceforge.net/installing.html. They are a bit out
of date, but they do cover the problem you are having.
JDH
From: Michael H. <mh...@us...> - 2008年06月25日 22:01:22
Attachments: build.err
I'm trying to install matplotlib on a RHEL5 system, and I'm getting 
errors in src/ft2font.h and ft2font.cpp.
An error log from the build command is attached.
I would use an RPM for this platform if I were sure that it would be 
installed in /usr/local/lib... Is there a way to control where RPM's 
get installed?
--Mike
-- 
------------------------------------------------------
Michael Hearne
mh...@us...
(303) 273-8620
USGS National Earthquake Information Center
1711 Illinois St. Golden CO 80401
Senior Software Engineer
Synergetics, Inc.
------------------------------------------------------
From: John H. <jd...@gm...> - 2008年06月25日 21:36:41
On Fri, Jun 20, 2008 at 9:32 PM, David Warde-Farley <dw...@cs...> wrote:
> Thanks again for the help. I was wondering about the code you posted --
> what's the problem with say, using bbox.xmin to adjust left only once? Or
> else perhaps get_text_width_height from the renderer? Wouldn't that yield
> the desired effect without the iterative procedure, since you'd immediately
> know (roughly) how much to push the subplot over?
Yes, that is a better approach. But you need to do a little work to
get the coordinate system width (going from width in pixels to
fractional width). Here is an example:
mport matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(range(10))
ax.set_yticks((2,5,7))
labels = ax.set_yticklabels(('really, really, really', 'long', 'labels'))
def on_draw(event):
 bboxes = []
 for label in labels:
 bbox = label.get_window_extent()
 # the figure transform goes from relative coords->pixels and we
 # want the inverse of that
 bboxi = bbox.inverse_transformed(fig.transFigure)
 bboxes.append(bboxi)
 # this is the bbox that bounds all the bboxes, again in relative
 # figure coords
 bbox = mtransforms.Bbox.union(bboxes)
 if fig.subplotpars.left < bbox.width:
 # we need to move it over
 fig.subplots_adjust(left=1.1*bbox.width) # pad a little
 fig.canvas.draw()
 return False
fig.canvas.mpl_connect('draw_event', on_draw)
plt.show()
From: John H. <jd...@gm...> - 2008年06月25日 21:21:26
On Fri, Jun 20, 2008 at 10:51 AM, Lubos Vrbka <li...@vr...> wrote:
> hi guys,
>
> my problem is probably simple, but i wasn't able to solve it. i use
> matplotlib with scipy/numpy (i.e., via pylab). in my program, i'd like
> to display interactively the convergence of a mathematical procedure.
You may want to take a look at the animation tutorial, which contains
some advice on how to make this stuff faster
http://www.scipy.org/Cookbook/Matplotlib/Animations
JDH
From: John H. <jd...@gm...> - 2008年06月25日 21:14:35
On Sun, Jun 22, 2008 at 3:18 AM, Paul Hartley <pha...@gm...> wrote:
>
> If I click on a bar that is part of a broken_barh collection which has its
> picker attribute enabled, there appears to be two events generated for
> example:
>
> def on_pick(self, event):
> print event.mouseevent.xdata
> print event.mouseevent.ydata
I am not seeing this with the latest mpl. Here is the example I am
using. For future reference, if you post s complete, self-contained
example we're much more likely to be able to help quickly. If I have
to write the example to see if there is a bug, I'm much more likely to
back-burner it.
from matplotlib.pyplot import figure, show
fig = figure()
ax = fig.add_subplot(111)
ax.broken_barh([ (110, 30), (150, 10) ] , (10, 9), picker=5)
ax.broken_barh([ (10, 50), (100, 20), (130, 10)] , (20, 9),
 facecolors=('red', 'yellow', 'green'), picker=5)
ax.set_ylim(5,35)
ax.set_xlim(0,200)
ax.set_xlabel('seconds since start')
ax.set_yticks([15,25])
ax.set_yticklabels(['Bill', 'Jim'])
ax.grid(True)
def on_pick(event):
 print event.artist, event.mouseevent.xdata, event.mouseevent.ydata
fig.canvas.mpl_connect('pick_event', on_pick)
show()
From: Tony S Yu <to...@MI...> - 2008年06月25日 19:13:04
Attachments: radar.py
I was reading through the projections docs and decided to take a shot 
at creating a radar chart class. The layout of the labels and legend 
is really off, but other than that, this seems to work OK. I couldn't 
figure out a good way to initialize the number of axes/variables, so 
there's an ugly function wrapping around the class def.
Anyway, I hope this is useful to somebody:
From: Delbert F. <dd...@iq...> - 2008年06月25日 16:15:56
On Monday 23 June 2008 23:00, Eric Firing wrote:
> Delbert Franz wrote:
> > I have been working to display an image of a USGS 7.5 minute quad sheet. 
> > These are provided at various locations about the Web. Since the 
> > range of colors on these maps is limited, the *.tif files appear to 
> > use an indexed color map wherein each pixel has a value 0 to 255 and 
> > the color is found from a table with 256 entries having triplets of
> > the RGB in the range of 0-255. I have not been able to sort out
> > how to get the gdal package to give me the color map from within python, so I dumped it
> > from the image file using gdalinfo and then cut and pasted to get
> > the following script:
> > 
> > ---------------------------------------------------------------------------------
> > import numpy as np
> > import matplotlib.pyplot as plt
> > import matplotlib.cm as cm
> > from matplotlib.colors import ListedColormap
> 
> from matplotlib.colors import NoNorm
> 
> > 
> > import osgeo.gdal as gdal
> > from osgeo.gdalconst import *
> > 
> > gd = gdal.Open('o37122d1.tif')
> > 
> > #Setup to compute the colormap from the RGB triplets from the geotif file
> > div = np.zeros( (256,3), np.float32)
> > 
> > ax = fig.add_subplot(111)
> > ax.imshow(suba, cmap=usgscm, origin='upper')
> 
> Instead, try:
> 
> ax.imshow(suba, cmap=usgscm, norm=NoNorm(), origin='upper')
> 
> 
> > 
> > plt.show()
> > ---------------------------------------------------------------------------------
> > This script does give me an image--but in badly wrong colors:( The script does 
> > properly display gray-scaled Digital Ortho-quadrangles using cm.gray as the color
> > map in imshow. Consequently something is not quite correct with respect to the 
> > definition or the use of the color map. It appears that each map, and there 
> > are about 56,000 of them available on one site, could have its own color map.
> > Thus my application must be able to compute a color map unique to each of the 
> > topographic maps. 
> > 
> > Questions:
> > 
> > 1. What am I missing to get imshow to pick out the correct colors from the 
> > color map?
> 
> The default norm will scale your inputs; specifying the norm as a NoNorm 
> instance will pass the integers through directly, so they will be used 
> as indices into the colormap.
> 
> 
> > 
> > 2. Should I be using the name, usgs, given in the ListedColormap instance someplace?
> > Not clear to me what role that name plays. 
> > 
> 
> None, really. I can imagine ways in which it could be useful, but 
> unless you know you need it, consider it optional.
> 
> 
> > 3. Is there a way to use ctab directly in the ListedColormap instance? Class Colormap
> > has a bytes argument, False by default, but I am not yet sure if it has any bearing
> > on my problem. 
> 
> No, sorry, but the bytes argument is only in the __call__ method, where 
> it is used to improve efficiency within mpl. There is no facility for 
> using ints in the lookup table, and no recognition of 0-255 ints within 
> mpl colorspecs, hence no way to feed your ctab in directly. Even if 
> there were, though, I don't think it would make much difference in 
> plotting time.
> 
> 
> Eric
> 
> > 
Eric,
That did the trick! The images are displaying properly now. Thanks
for the quick help. 
 Delbert
From: Mathieu L. <lep...@gm...> - 2008年06月25日 14:50:35
Well, I'll give a try towards another possibility :
 1 - use SVG output with rc setting : svg.embed_char_paths" to False
 2 - use cairo to export to PNG/JPG etc..
Step 1 works great natively with Arabic (at least viewing it with Inkscape).
Let's see if I have problems with step 2.
2008年6月25日 Darren Dale <dsd...@gm...>:
> Hi Mathieu,
>
> Are there perhaps some latex packages you could load using the
> text.latex.preamble rc setting? This setting is officially unsupported, but
> it would be much easier than adding an option to use the xetex executable
> (which would probably not be officially supported by mpl).
>
> Darren
>
> On Wednesday 25 June 2008 09:02:41 am Mathieu Leplatre wrote:
>> Hi all,
>>
>> I have been trying to follow your tips regarding matplotlib and arabic
>> support.
>>
>> Indeed matplotlib with Latex and unicode work great together :
>>
>> #-*- coding: utf-8 -*-
>> from pylab import *
>> from matplotlib import rcParams
>> rcParams['text.usetex']=True
>> rcParams['text.latex.unicode']=True
>> figure(1)
>> plot([1,2,3])
>> title(unicode(r'\textit{éèê}','utf8'))
>> show()
>>
>> But then I came to the conclusion that Latex did not support Arabic.
>> This few lines generate a "missing def" error.
>>
>> \documentclass{article}
>> \usepackage{ucs}
>> \usepackage[utf8x]{inputenc}
>> \title{éèê هه}
>> \begin{document}
>> \maketitle
>> \end{document}
>>
>> Is it related to my installation ? (Ubuntu with package
>> texlive-latex-recommended)
>> I asked here : http://ubuntuforums.org/showthread.php?p=5258457
>>
>> Somebody pointed me out XeTeX, which has wider support for Unicode.
>> www.tug.org/TUGboat/Articles/tb27-2/tb87kew.pdf
>>
>> I was wondering if there could be a way to get matplotlib work with XeTeX.
>>
>> What do you think ? Is it the right track ? Should I switch to
>> grandpa's gnuplot :) ?
>>
>> Thank you all,
>>
>> Mathieu.
>>
>> Michael Droettboom wrote:
>> > Unfortunately, I believe this is a fundamental incompatibility within
>> > matplotlib. matplotlib uses a very simple algorithm for layout out a
>> > line of characters which assumes ltr order and all kinds of other things.
>> >
>> > That said, there is something you could try. Matplotlib has a "usetex"
>> > mode which will do all text rendering using LaTeX. Assuming you can get
>> > LaTeX to handle Arabic correctly, you can set the following in your
>> > .matplotlibrc file:
>> >
>> > text.usetex : True
>> > text.latex.unicode : True
>> >
>> > You'll need to install the LaTeX Unicode extension "ucs" (Ubuntu
>> > probably has packages for that.) If you need to load any LaTeX packages
>> > to get arabic support, you can tell matplotlib about them in your
>> > matplotlibrc like so:
>> >
>> > text.latex.preamble: \usepackage{foo}
>> >
>> > If Arabic-encoded-as-Unicode doesn't work, you could try setting
>> > "text.latex.unicode" to False, and then typing your Arabic strings using
>> > one of the other Arabic encodings that LaTeX understands.
>> >
>> > Please let us know if you have success or hit another roadblock.
>> >
>> > Cheers,
>> > Mike
>> >
>> > Burhan Khalid wrote:
>> >> Hello All:
>> >>
>> >> Having an issue with Arabic font support using matplotlib. When using
>> >> the correct font, Arabic characters are displayed, but are not joined
>> >> together
>> >> properly; and they are also not in the correct order (the font rendered
>> >> is ltr, but Arabic is a rtl language). Is this an issue with the render
>> >> I am using, or some incompatibility within matplotlib? Sample source
>> >> code used (please note, your email client should support utf8 to display
>> >> the code correctly).
>> >>
>> >> #-*- coding: utf-8 -*-
>> >> from pylab import *
>> >> figure(1) # the first figure
>> >> plot([1,2,3])
>> >> figure(1) # figure 1 current
>> >> title(u'برهان',name='Times New Roman') # figure 1 title
>> >> savefig('test.png')
>> >> savefig('test.eps')
>> >> show()
>> >>
>> >> Output when run from the command line:
>> >>
>> >> matplotlib data path /usr/share/matplotlib/mpl-data
>> >> $HOME=/home/burhan
>> >> CONFIGDIR=/home/burhan/.matplotlib
>> >> loaded rc file /etc/matplotlibrc
>> >> matplotlib version 0.90.1
>> >> verbose.level helpful
>> >> interactive is False
>> >> units is True
>> >> platform is linux2
>> >> numerix numpy 1.0.3
>> >> font search path ['/usr/share/matplotlib/mpl-data/fonts/ttf',
>> >> '/usr/share/matplotlib/mpl-data/fonts/afm']
>> >> loaded ttfcache file /home/burhan/.matplotlib/ttffont.cache
>> >> backend TkAgg version 8.4
>> >> Could not match Bitstream Vera Serif, New Century Schoolbook, Century
>> >> Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times
>> >> New Roman, Times, Palatino, Charter, serif, normal, normal. Returning
>> >> /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
>> >>
>> >> This is on a clean Ubuntu Gutsy install, using python 2.5.1.
>> >>
>> >> Thanks,
>> >> Burhan
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------
>> >>
>> >> ------------------------------------------------------------------------
>> >>- This SF.net email is sponsored by: Splunk Inc.
>> >> Still grepping through log files to find problems? Stop.
>> >> Now Search log events and configuration files using AJAX and a browser.
>> >> Download your FREE copy of Splunk now >> http://get.splunk.com/
>> >>
>> >>
>> >> ------------------------------------------------------------------------
>> >>
>> >> _______________________________________________
>> >> Matplotlib-users mailing list
>> >> Mat...@li...
>> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> >
>> > --
>> > Michael Droettboom
>> > Science Software Branch
>> > Operations and Engineering Division
>> > Space Telescope Science Institute
>> > Operated by AURA for NASA
>> >
>> > -------------------------------------------------------------------------
>> > This SF.net email is sponsored by: Splunk Inc.
>> > Still grepping through log files to find problems? Stop.
>> > Now Search log events and configuration files using AJAX and a browser.
>> > Download your FREE copy of Splunk now >> http://get.splunk.com/
>> > _______________________________________________
>> > Matplotlib-users mailing list
>> > Mat...@li...
>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>> -------------------------------------------------------------------------
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://sourceforge.net/services/buy/index.php
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
From: Darren D. <dsd...@gm...> - 2008年06月25日 14:10:45
Hi Mathieu,
Are there perhaps some latex packages you could load using the 
text.latex.preamble rc setting? This setting is officially unsupported, but 
it would be much easier than adding an option to use the xetex executable 
(which would probably not be officially supported by mpl).
Darren
On Wednesday 25 June 2008 09:02:41 am Mathieu Leplatre wrote:
> Hi all,
>
> I have been trying to follow your tips regarding matplotlib and arabic
> support.
>
> Indeed matplotlib with Latex and unicode work great together :
>
> #-*- coding: utf-8 -*-
> from pylab import *
> from matplotlib import rcParams
> rcParams['text.usetex']=True
> rcParams['text.latex.unicode']=True
> figure(1)
> plot([1,2,3])
> title(unicode(r'\textit{éèê}','utf8'))
> show()
>
> But then I came to the conclusion that Latex did not support Arabic.
> This few lines generate a "missing def" error.
>
> \documentclass{article}
> \usepackage{ucs}
> \usepackage[utf8x]{inputenc}
> \title{éèê هه}
> \begin{document}
> \maketitle
> \end{document}
>
> Is it related to my installation ? (Ubuntu with package
> texlive-latex-recommended)
> I asked here : http://ubuntuforums.org/showthread.php?p=5258457
>
> Somebody pointed me out XeTeX, which has wider support for Unicode.
> www.tug.org/TUGboat/Articles/tb27-2/tb87kew.pdf
>
> I was wondering if there could be a way to get matplotlib work with XeTeX.
>
> What do you think ? Is it the right track ? Should I switch to
> grandpa's gnuplot :) ?
>
> Thank you all,
>
> Mathieu.
>
> Michael Droettboom wrote:
> > Unfortunately, I believe this is a fundamental incompatibility within
> > matplotlib. matplotlib uses a very simple algorithm for layout out a
> > line of characters which assumes ltr order and all kinds of other things.
> >
> > That said, there is something you could try. Matplotlib has a "usetex"
> > mode which will do all text rendering using LaTeX. Assuming you can get
> > LaTeX to handle Arabic correctly, you can set the following in your
> > .matplotlibrc file:
> >
> > text.usetex : True
> > text.latex.unicode : True
> >
> > You'll need to install the LaTeX Unicode extension "ucs" (Ubuntu
> > probably has packages for that.) If you need to load any LaTeX packages
> > to get arabic support, you can tell matplotlib about them in your
> > matplotlibrc like so:
> >
> > text.latex.preamble: \usepackage{foo}
> >
> > If Arabic-encoded-as-Unicode doesn't work, you could try setting
> > "text.latex.unicode" to False, and then typing your Arabic strings using
> > one of the other Arabic encodings that LaTeX understands.
> >
> > Please let us know if you have success or hit another roadblock.
> >
> > Cheers,
> > Mike
> >
> > Burhan Khalid wrote:
> >> Hello All:
> >>
> >> Having an issue with Arabic font support using matplotlib. When using
> >> the correct font, Arabic characters are displayed, but are not joined
> >> together
> >> properly; and they are also not in the correct order (the font rendered
> >> is ltr, but Arabic is a rtl language). Is this an issue with the render
> >> I am using, or some incompatibility within matplotlib? Sample source
> >> code used (please note, your email client should support utf8 to display
> >> the code correctly).
> >>
> >> #-*- coding: utf-8 -*-
> >> from pylab import *
> >> figure(1) # the first figure
> >> plot([1,2,3])
> >> figure(1) # figure 1 current
> >> title(u'برهان',name='Times New Roman') # figure 1 title
> >> savefig('test.png')
> >> savefig('test.eps')
> >> show()
> >>
> >> Output when run from the command line:
> >>
> >> matplotlib data path /usr/share/matplotlib/mpl-data
> >> $HOME=/home/burhan
> >> CONFIGDIR=/home/burhan/.matplotlib
> >> loaded rc file /etc/matplotlibrc
> >> matplotlib version 0.90.1
> >> verbose.level helpful
> >> interactive is False
> >> units is True
> >> platform is linux2
> >> numerix numpy 1.0.3
> >> font search path ['/usr/share/matplotlib/mpl-data/fonts/ttf',
> >> '/usr/share/matplotlib/mpl-data/fonts/afm']
> >> loaded ttfcache file /home/burhan/.matplotlib/ttffont.cache
> >> backend TkAgg version 8.4
> >> Could not match Bitstream Vera Serif, New Century Schoolbook, Century
> >> Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times
> >> New Roman, Times, Palatino, Charter, serif, normal, normal. Returning
> >> /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
> >>
> >> This is on a clean Ubuntu Gutsy install, using python 2.5.1.
> >>
> >> Thanks,
> >> Burhan
> >>
> >>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> ------------------------------------------------------------------------
> >>- This SF.net email is sponsored by: Splunk Inc.
> >> Still grepping through log files to find problems? Stop.
> >> Now Search log events and configuration files using AJAX and a browser.
> >> Download your FREE copy of Splunk now >> http://get.splunk.com/
> >>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> Matplotlib-users mailing list
> >> Mat...@li...
> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> > --
> > Michael Droettboom
> > Science Software Branch
> > Operations and Engineering Division
> > Space Telescope Science Institute
> > Operated by AURA for NASA
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc.
> > Still grepping through log files to find problems? Stop.
> > Now Search log events and configuration files using AJAX and a browser.
> > Download your FREE copy of Splunk now >> http://get.splunk.com/
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Michael D. <md...@st...> - 2008年06月25日 14:08:34
Mathieu Leplatre wrote:
> Hi all,
>
> I have been trying to follow your tips regarding matplotlib and arabic support.
> 
> Is it related to my installation ? (Ubuntu with package
> texlive-latex-recommended)
> I asked here : http://ubuntuforums.org/showthread.php?p=5258457
> 
I have no idea. Try asking on a texlive forum, perhaps.
Do you have a real need for using "usetex", or are you just doing that 
given my suggestion from last October?
Here's the thing to keep in mind: matplotlib's built-in text layout 
algorithm is completely English-centric. It assumes all text is left to 
right and doesn't deal with any of Unicode's complications like 
combining characters etc. We really should be using a proper text 
layout engine like Pango or ICU TextLayout that has all these things 
worked out. matplotlib in general avoids (L)GPL'd libraries for core 
functionality so Pango is probably out. And ICU TextLayout doesn't 
appear to have Python bindings, adding another speed bump to its use. I 
think it needs a highly-motivated developer to take it on. 
Unfortunately, I think many of us are in the head-in-the-sand about 
internationalization United States... ;)
So the trick here for matplotlib (ignoring the LaTeX/XeTeX issues for 
now), is to avoid its built-in text layout. The Agg, Pdf and Ps 
backends are basically forced to use it by the nature of the format and 
implementations. The Cairo backend could do it if we used pangocairo, 
but at the moment we use Cairo's "toy" text API which doesn't have all 
the Pango goodness. It turns out that (basically by accident) the SVG 
backend *does* work, if you set "svg.embed_char_paths" to False. In 
that mode, it outputs "real" SVG text as strings that appear (to my 
non-Arabic-reading eyes) to be interpreted correctly r-to-l in 
Inkscape. Note, however, that matplotlib will get the length of the 
text wrong, so the text is slightly off-center. But it's a start.
Now, on to the LaTeX-based solution. I'm a bit out of my element here 
and only suggesting things that I might try next. No guarantees of 
working at all. I haven't spent much time with matplotlib's usetex code.
> Somebody pointed me out XeTeX, which has wider support for Unicode.
> www.tug.org/TUGboat/Articles/tb27-2/tb87kew.pdf
>
> I was wondering if there could be a way to get matplotlib work with XeTeX.
> 
I don't have XeTeX installed here (and don't have root access to my 
machine at work), so I can't easily try it. You could experiment, 
however, by replacing
 command = self._get_shell_cmd('cd "%s"'% self.texcache,
 'latex -interaction=nonstopmode %s > "%s"'\
 %(os.path.split(texfile)[-1], outfile))
with
 command = self._get_shell_cmd('cd "%s"'% self.texcache,
 'xelatex --no-pdf -interaction=nonstopmode 
%s > "%s"'\
 %(os.path.split(texfile)[-1], outfile))
Make sure text.latex.unicode is set to False, so that the ucs packages, 
which are incompatible with XeTeX, are not loaded.
A couple of things may stand in the way -- xetex, with the --no-pdf 
option, outputs "xdv" (extended dvi), rather than "dvi". matplotlib 
inserts LaTeX text by converting dvi to png or ps (with dvipng or dvips 
respectively). I don't know how backward-compatible xdv is as a format 
and whether that's a show stopper.
If you get somewhere and get stuck again, please post your progress and 
all console output etc. here and I can try to get you unstuck again.
> What do you think ? Is it the right track ? Should I switch to
> grandpa's gnuplot :) ?
> 
Well, gnuplot does use pango, apparently, so it has that advantage, if 
nothing else... ;)
Cheers,
Mike
> Thank you all,
>
> Mathieu.
>
>
> Michael Droettboom wrote:
> 
>> Unfortunately, I believe this is a fundamental incompatibility within
>> matplotlib. matplotlib uses a very simple algorithm for layout out a
>> line of characters which assumes ltr order and all kinds of other things.
>>
>> That said, there is something you could try. Matplotlib has a "usetex"
>> mode which will do all text rendering using LaTeX. Assuming you can get
>> LaTeX to handle Arabic correctly, you can set the following in your
>> .matplotlibrc file:
>>
>> text.usetex : True
>> text.latex.unicode : True
>>
>> You'll need to install the LaTeX Unicode extension "ucs" (Ubuntu
>> probably has packages for that.) If you need to load any LaTeX packages
>> to get arabic support, you can tell matplotlib about them in your
>> matplotlibrc like so:
>>
>> text.latex.preamble: \usepackage{foo}
>>
>> If Arabic-encoded-as-Unicode doesn't work, you could try setting
>> "text.latex.unicode" to False, and then typing your Arabic strings using
>> one of the other Arabic encodings that LaTeX understands.
>>
>> Please let us know if you have success or hit another roadblock.
>>
>> Cheers,
>> Mike
>>
>> Burhan Khalid wrote:
>> 
>>> Hello All:
>>>
>>> Having an issue with Arabic font support using matplotlib. When using
>>> the correct font, Arabic characters are displayed, but are not joined
>>> together
>>> properly; and they are also not in the correct order (the font rendered is
>>> ltr, but Arabic is a rtl language). Is this an issue with the render I
>>> am using, or some incompatibility within matplotlib? Sample source code
>>> used (please note, your email client should support utf8 to display the
>>> code correctly).
>>>
>>> #-*- coding: utf-8 -*-
>>> from pylab import *
>>> figure(1) # the first figure
>>> plot([1,2,3])
>>> figure(1) # figure 1 current
>>> title(u'برهان',name='Times New Roman') # figure 1 title
>>> savefig('test.png')
>>> savefig('test.eps')
>>> show()
>>>
>>> Output when run from the command line:
>>>
>>> matplotlib data path /usr/share/matplotlib/mpl-data
>>> $HOME=/home/burhan
>>> CONFIGDIR=/home/burhan/.matplotlib
>>> loaded rc file /etc/matplotlibrc
>>> matplotlib version 0.90.1
>>> verbose.level helpful
>>> interactive is False
>>> units is True
>>> platform is linux2
>>> numerix numpy 1.0.3
>>> font search path ['/usr/share/matplotlib/mpl-data/fonts/ttf',
>>> '/usr/share/matplotlib/mpl-data/fonts/afm']
>>> loaded ttfcache file /home/burhan/.matplotlib/ttffont.cache
>>> backend TkAgg version 8.4
>>> Could not match Bitstream Vera Serif, New Century Schoolbook, Century
>>> Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times
>>> New Roman, Times, Palatino, Charter, serif, normal, normal. Returning
>>> /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
>>>
>>> This is on a clean Ubuntu Gutsy install, using python 2.5.1.
>>>
>>> Thanks,
>>> Burhan
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> -------------------------------------------------------------------------
>>> This SF.net email is sponsored by: Splunk Inc.
>>> Still grepping through log files to find problems? Stop.
>>> Now Search log events and configuration files using AJAX and a browser.
>>> Download your FREE copy of Splunk now >> http://get.splunk.com/
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>> 
>> --
>> Michael Droettboom
>> Science Software Branch
>> Operations and Engineering Division
>> Space Telescope Science Institute
>> Operated by AURA for NASA
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems? Stop.
>> Now Search log events and configuration files using AJAX and a browser.
>> Download your FREE copy of Splunk now >> http://get.splunk.com/
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: John H. <jd...@gm...> - 2008年06月25日 13:49:59
On Wed, Jun 25, 2008 at 6:05 AM, izak marais <iza...@ya...> wrote:
> Hi,
>
> I see there is a "hatch: unknown" kwarg mentioned in the hist()
> documentation. Can anyone shed some light on how to use this please? I
> assume it might be used to generate monochrome rectangles with
> differentiating hatched fills?
The rectangles generates by "hist" are matplotlib.patch.Rectangle
instances, and the "hatch" property is controlled by the "set_hatch"
method. Here is the docstring which should tell you most everything
you need to know. Note the caveat at the end that it is only
currently supported on postscript -- patches for other backends much
obliged
 def set_hatch(self, h):
 """
 Set the hatching pattern
 hatch can be one of::
 / - diagonal hatching
 \ - back diagonal
 | - vertical
 - - horizontal
 # - crossed
 x - crossed diagonal
 Letters can be combined, in which case all the specified
 hatchings are done. If same letter repeats, it increases the
 density of hatching in that direction.
 CURRENT LIMITATIONS:
 1. Hatching is supported in the PostScript backend only.
 2. Hatching is done with solid black lines of width 0.
From: John H. <jd...@gm...> - 2008年06月25日 13:46:26
On Wed, Jun 25, 2008 at 7:31 AM, eShopping
<etr...@ds...> wrote:
> Hi Darren
>
> thanks for the quick reply. I tried
>
> self.lines[0][0].set_data((self.data.xa,self.data.ya))
> self.lines[0][1].set_data((self.data.xa,self.data.ys))
>
> but got the error 'list index out of range' after the second
> statement. I also tried
>
> self.lines[0][0].set_data((self.data.xa,self.data.ya))
> self.lines[1][0].set_data((self.data.xa,self.data.ys))
>
> There were no errors in this case but the data does not plot
> correctly. Finally, I tried
>
> self.lines[0][0].set_xdata(self.data.xa)
> self.lines[0][0].set_ydata(self.data.ya)
> self.lines[1][0].set_xdata(self.data.xa)
> self.lines[1][0].set_ydata(self.data.ys)
>
> but matplotlib complained that 'xdata and ydata must be the same
> length' after executing the first of these statements (presumably
> because the new xa array has a different number of elements than the
> old ya array)
The self.lines[0][1] idiom is really ugly. Avoid it with Darren't
first suggestions::
 self.lines.extend(ax.plot(something))
If the xdata or ydata change in size, you will need to set them both
simultaneously:
 line.set_data(xdata, ydata)
JDH
From: John H. <jd...@gm...> - 2008年06月25日 13:44:17
On Tue, Jun 24, 2008 at 8:13 AM, Adam Mercer <ram...@gm...> wrote:
> What's strange is that if I comment out the plotting of the second
> test data set then the plot is produced without error, even though the
> reported error (when plotting both data sets) seems to have nothing to
> do with the second data set.
Hey Adam,
I think I have this fixed in svn -- also, I rewrote your example to
use csv2rec (which returns record arrays). Thought you might be
interested:
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.cbook as cbook
r1 = mlab.csv2rec('test1.dat', names='date,value', delimiter=' ',
 converterd={'date':cbook.todate('%Y%m%d')})
r2 = mlab.csv2rec('test2.dat', names='date,value', delimiter=' ',
 converterd={'date':cbook.todate('%Y%m%d')})
print 'dtype', r1.dtype
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()
# produce plot
line1, = ax1.plot(r1.date, r1.value, 'bo-')
line2, = ax2.plot(r2.date, r2.value, 'bo-')
# set up axes
ax1.xaxis.set_major_locator(mdates.DayLocator(range(0, 31, 2)))
ax1.xaxis.set_minor_locator(mdates.DayLocator(range(0, 31, 1)))
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y/%m/%d'))
plt.show()
From: Adam M. <ram...@gm...> - 2008年06月25日 13:19:40
On Wed, Jun 25, 2008 at 7:21 AM, Darren Dale <dsd...@gm...> wrote:
> I don't see a problem here. I did the following:
>
> ipython -pylab
> run two_scales.py
> ax1.yaxis.set_minor_locator(MultipleLocator(1000))
> draw()
> # Shows minor ticks on both left and right yaxis
> ax1.yaxis.tick_left()
> draw()
> # shows minor ticks on left only
> ax2.yaxis.set_minor_locator(MultipleLocator(.1))
> draw()
> # shows left yaxis minor ticks on left only, shows right yaxis ticks on both
> ax2.yaxis.tick_right()
> draw()
> # shows left yaxis minor ticks on left only, right yaxis minor ticks on
> # right only
Thanks Darren, that solves it. I was calling tick_left() and
tick_right() before calling set_{major,minor}_locator(). Moving these
calls to after the ticks have been set solves the problem.
Cheers
Adam
> Darren
>
From: Mathieu L. <lep...@gm...> - 2008年06月25日 13:02:44
Hi all,
I have been trying to follow your tips regarding matplotlib and arabic support.
Indeed matplotlib with Latex and unicode work great together :
#-*- coding: utf-8 -*-
from pylab import *
from matplotlib import rcParams
rcParams['text.usetex']=True
rcParams['text.latex.unicode']=True
figure(1)
plot([1,2,3])
title(unicode(r'\textit{éèê}','utf8'))
show()
But then I came to the conclusion that Latex did not support Arabic.
This few lines generate a "missing def" error.
\documentclass{article}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\title{éèê هه}
\begin{document}
\maketitle
\end{document}
Is it related to my installation ? (Ubuntu with package
texlive-latex-recommended)
I asked here : http://ubuntuforums.org/showthread.php?p=5258457
Somebody pointed me out XeTeX, which has wider support for Unicode.
www.tug.org/TUGboat/Articles/tb27-2/tb87kew.pdf
I was wondering if there could be a way to get matplotlib work with XeTeX.
What do you think ? Is it the right track ? Should I switch to
grandpa's gnuplot :) ?
Thank you all,
Mathieu.
Michael Droettboom wrote:
> Unfortunately, I believe this is a fundamental incompatibility within
> matplotlib. matplotlib uses a very simple algorithm for layout out a
> line of characters which assumes ltr order and all kinds of other things.
>
> That said, there is something you could try. Matplotlib has a "usetex"
> mode which will do all text rendering using LaTeX. Assuming you can get
> LaTeX to handle Arabic correctly, you can set the following in your
> .matplotlibrc file:
>
> text.usetex : True
> text.latex.unicode : True
>
> You'll need to install the LaTeX Unicode extension "ucs" (Ubuntu
> probably has packages for that.) If you need to load any LaTeX packages
> to get arabic support, you can tell matplotlib about them in your
> matplotlibrc like so:
>
> text.latex.preamble: \usepackage{foo}
>
> If Arabic-encoded-as-Unicode doesn't work, you could try setting
> "text.latex.unicode" to False, and then typing your Arabic strings using
> one of the other Arabic encodings that LaTeX understands.
>
> Please let us know if you have success or hit another roadblock.
>
> Cheers,
> Mike
>
> Burhan Khalid wrote:
>> Hello All:
>>
>> Having an issue with Arabic font support using matplotlib. When using
>> the correct font, Arabic characters are displayed, but are not joined
>> together
>> properly; and they are also not in the correct order (the font rendered is
>> ltr, but Arabic is a rtl language). Is this an issue with the render I
>> am using, or some incompatibility within matplotlib? Sample source code
>> used (please note, your email client should support utf8 to display the
>> code correctly).
>>
>> #-*- coding: utf-8 -*-
>> from pylab import *
>> figure(1) # the first figure
>> plot([1,2,3])
>> figure(1) # figure 1 current
>> title(u'برهان',name='Times New Roman') # figure 1 title
>> savefig('test.png')
>> savefig('test.eps')
>> show()
>>
>> Output when run from the command line:
>>
>> matplotlib data path /usr/share/matplotlib/mpl-data
>> $HOME=/home/burhan
>> CONFIGDIR=/home/burhan/.matplotlib
>> loaded rc file /etc/matplotlibrc
>> matplotlib version 0.90.1
>> verbose.level helpful
>> interactive is False
>> units is True
>> platform is linux2
>> numerix numpy 1.0.3
>> font search path ['/usr/share/matplotlib/mpl-data/fonts/ttf',
>> '/usr/share/matplotlib/mpl-data/fonts/afm']
>> loaded ttfcache file /home/burhan/.matplotlib/ttffont.cache
>> backend TkAgg version 8.4
>> Could not match Bitstream Vera Serif, New Century Schoolbook, Century
>> Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times
>> New Roman, Times, Palatino, Charter, serif, normal, normal. Returning
>> /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
>>
>> This is on a clean Ubuntu Gutsy install, using python 2.5.1.
>>
>> Thanks,
>> Burhan
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems? Stop.
>> Now Search log events and configuration files using AJAX and a browser.
>> Download your FREE copy of Splunk now >> http://get.splunk.com/
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
> --
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: eShopping <etr...@ds...> - 2008年06月25日 12:31:59
Hi Darren
thanks for the quick reply. I tried
self.lines[0][0].set_data((self.data.xa,self.data.ya))
self.lines[0][1].set_data((self.data.xa,self.data.ys))
but got the error 'list index out of range' after the second 
statement. I also tried
self.lines[0][0].set_data((self.data.xa,self.data.ya))
self.lines[1][0].set_data((self.data.xa,self.data.ys))
There were no errors in this case but the data does not plot 
correctly. Finally, I tried
self.lines[0][0].set_xdata(self.data.xa)
self.lines[0][0].set_ydata(self.data.ya)
self.lines[1][0].set_xdata(self.data.xa)
self.lines[1][0].set_ydata(self.data.ys)
but matplotlib complained that 'xdata and ydata must be the same 
length' after executing the first of these statements (presumably 
because the new xa array has a different number of elements than the 
old ya array)
At 13:05 25/06/2008, you wrote:
>Hi Alun,
>
>On Wednesday 25 June 2008 07:09:52 am eShopping wrote:
> > Hi
> >
> > the following code snippet is from a simple wxpython/matplotlib app
> >
> > # Data object class
> >
> > class PlotData(object):
> >
> > # Constructor (dummy arrays)
> >
> > def __init__(self):
> > self.np = 100
> >
> > self.xa = numpy.arange(100.0)
> > self.ya = 2.0 * self.xa
> > self.ys = 4.0 * self.xa
> >
> >
> > # Plot window class
> >
> > class PlotWin(object):
> > def __init__(self, data):
> > self.data = data # Store reference to data object
> > self.figure = Figure() # Initialise figure
> >
> > # Create an Axes object to plot on
> >
> > self.ax1 = self.figure.gca()
> > self.ax1.yaxis.tick_left()
> > self.ax1.xaxis.tick_bottom()
> >
> > # Plot the data
> >
> > self.lines=[]
> >
> > self.lines.append(self.ax1.plot(self.data.xa, self.data.ya, 'g'))
> > self.lines.append(self.ax1.plot(self.data.xa, self.data.ys, '-r'))
> >
> >
> > # Update plot with new data
> >
> > def RefreshPlot(self, data):
> > self.lines[0].set_data((self.data.xa,self.data.ya))
> > self.lines[1].set_data((self.data.xa,self.data.ys))
> >
> > self.canvas.draw()
> >
> >
> > # Main program
> >
> > if __name__ == "__main__":
> > data = PlotData()
> > pwin = PlotWin(data)
> > pwin.RefreshPlot(data)
> >
> > The plot data changes during the application and I just want to
> > replace the existing data with the new data (which may have a
> > different number of points compared to the old data). I get the
> > Python error "'list' object has no attribute 'set_data'" when the
> > code executes RefreshPlot(). AFAIK lines[0] and lines[1] are
> > 'Line2D' objects (at least that's what Python says they are when I
> > ask to have them printed) , which do have a 'set_data' method. I'm
> > sure there's something really easy that I need to do but just can't
> > see it - all suggestions gratefully received!
>
>I think the problem is:
>
>self.lines.append(self.ax1.plot(self.data.xa, self.data.ya, 'g'))
>
>plot() returns a list of lines. You are appending that list to self.lines, so
>when you index self.lines[0] later, you are getting the list returned by
>plot. You should either use extend() instead of append, or you need to index
>deeper: self.lines[0][0] and self.lines[0][1].
>
>Darren
From: Darren D. <dsd...@gm...> - 2008年06月25日 12:21:40
On Monday 23 June 2008 08:53:56 pm Adam Mercer wrote:
> Hi
>
> Anyone know how to fix this problem?
>
> Cheers
>
> Adam
>
> On Thu, Jun 19, 2008 at 8:31 PM, Adam Mercer <ram...@gm...> wrote:
> > Hi
> >
> > I have a plot that has two different y-axis scales and I want
> > appropriate tick marks for the different y-axes. ie I want the tick
> > marks on the left axis to correspond to the scale on the left axis
> > etc... As far as I can tell the way to accomplish this, after
> > consulting the documentation, is to use the tick_left() and
> > tick_right() methods, I therefore have the following code:
> >
> > axes1.yaxis.tick_left()
> > axes1.yaxis.set_major_locator(pylab.MultipleLocator(0.1))
> > axes1.yaxis.set_minor_locator(pylab.MultipleLocator(0.05))
> > axes2.yaxis.tick_right()
> > axes2.yaxis.set_major_locator(pylab.MultipleLocator(5))
> > axes2.yaxis.set_minor_locator(pylab.MultipleLocator(1))
> >
> > but the minor ticks are on both the left and right y-axes. How can I
> > make the minor ticks for axes1 only appear on the the left and the
> > minor ticks for axes2 appear on the right?
I don't see a problem here. I did the following:
ipython -pylab
run two_scales.py
ax1.yaxis.set_minor_locator(MultipleLocator(1000))
draw()
# Shows minor ticks on both left and right yaxis
 ax1.yaxis.tick_left()
draw()
# shows minor ticks on left only
ax2.yaxis.set_minor_locator(MultipleLocator(.1))
draw()
# shows left yaxis minor ticks on left only, shows right yaxis ticks on both
ax2.yaxis.tick_right()
draw()
# shows left yaxis minor ticks on left only, right yaxis minor ticks on 
# right only
Darren
From: Darren D. <dsd...@gm...> - 2008年06月25日 12:11:03
Hi Alun,
On Wednesday 25 June 2008 07:09:52 am eShopping wrote:
> Hi
>
> the following code snippet is from a simple wxpython/matplotlib app
>
> # Data object class
>
> class PlotData(object):
>
> # Constructor (dummy arrays)
>
> def __init__(self):
> self.np = 100
>
> self.xa = numpy.arange(100.0)
> self.ya = 2.0 * self.xa
> self.ys = 4.0 * self.xa
>
>
> # Plot window class
>
> class PlotWin(object):
> def __init__(self, data):
> self.data = data # Store reference to data object
> self.figure = Figure() # Initialise figure
>
> # Create an Axes object to plot on
>
> self.ax1 = self.figure.gca()
> self.ax1.yaxis.tick_left()
> self.ax1.xaxis.tick_bottom()
>
> # Plot the data
>
> self.lines=[]
>
> self.lines.append(self.ax1.plot(self.data.xa, self.data.ya, 'g'))
> self.lines.append(self.ax1.plot(self.data.xa, self.data.ys, '-r'))
>
>
> # Update plot with new data
>
> def RefreshPlot(self, data):
> self.lines[0].set_data((self.data.xa,self.data.ya))
> self.lines[1].set_data((self.data.xa,self.data.ys))
>
> self.canvas.draw()
>
>
> # Main program
>
> if __name__ == "__main__":
> data = PlotData()
> pwin = PlotWin(data)
> pwin.RefreshPlot(data)
>
> The plot data changes during the application and I just want to
> replace the existing data with the new data (which may have a
> different number of points compared to the old data). I get the
> Python error "'list' object has no attribute 'set_data'" when the
> code executes RefreshPlot(). AFAIK lines[0] and lines[1] are
> 'Line2D' objects (at least that's what Python says they are when I
> ask to have them printed) , which do have a 'set_data' method. I'm
> sure there's something really easy that I need to do but just can't
> see it - all suggestions gratefully received!
I think the problem is:
self.lines.append(self.ax1.plot(self.data.xa, self.data.ya, 'g'))
plot() returns a list of lines. You are appending that list to self.lines, so 
when you index self.lines[0] later, you are getting the list returned by 
plot. You should either use extend() instead of append, or you need to index 
deeper: self.lines[0][0] and self.lines[0][1].
Darren
From: eShopping <etr...@ds...> - 2008年06月25日 11:10:10
Hi
the following code snippet is from a simple wxpython/matplotlib app
# Data object class
class PlotData(object):
 # Constructor (dummy arrays)
 def __init__(self):
 self.np = 100
 self.xa = numpy.arange(100.0)
 self.ya = 2.0 * self.xa
 self.ys = 4.0 * self.xa
# Plot window class
class PlotWin(object):
 def __init__(self, data):
 self.data = data # Store reference to data object
 self.figure = Figure() # Initialise figure
 # Create an Axes object to plot on
 self.ax1 = self.figure.gca()
 self.ax1.yaxis.tick_left()
 self.ax1.xaxis.tick_bottom()
 # Plot the data
 self.lines=[]
 self.lines.append(self.ax1.plot(self.data.xa, self.data.ya, 'g'))
 self.lines.append(self.ax1.plot(self.data.xa, self.data.ys, '-r'))
 # Update plot with new data
 def RefreshPlot(self, data):
 self.lines[0].set_data((self.data.xa,self.data.ya))
 self.lines[1].set_data((self.data.xa,self.data.ys))
 self.canvas.draw()
# Main program
if __name__ == "__main__":
 data = PlotData()
 pwin = PlotWin(data)
 pwin.RefreshPlot(data)
The plot data changes during the application and I just want to 
replace the existing data with the new data (which may have a 
different number of points compared to the old data). I get the 
Python error "'list' object has no attribute 'set_data'" when the 
code executes RefreshPlot(). AFAIK lines[0] and lines[1] are 
'Line2D' objects (at least that's what Python says they are when I 
ask to have them printed) , which do have a 'set_data' method. I'm 
sure there's something really easy that I need to do but just can't 
see it - all suggestions gratefully received!
Thanks in advance
Alun Griffiths
From: izak m. <iza...@ya...> - 2008年06月25日 11:05:41
Hi,
I see there is a "hatch: unknown" kwarg mentioned in the hist() documentation. Can anyone shed some light on how to use this please? I assume it might be used to generate monochrome rectangles with differentiating hatched fills?
Regards
Izak
 

Showing 22 results of 22

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