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





Showing results of 29

1 2 > >> (Page 1 of 2)
From: Christopher B. <Chr...@no...> - 2008年03月27日 22:13:11
Ronald Oussoren wrote:
> That load command is for LC_UUID. The version of macholib in subversion 
> should have some support that is (basicly ignoring the entire load 
> command because macholib won't have to change it), could you test that 
> (easy_install macholib==dev)?
Yup, that problem is solved. Now it complains that I don't have wxPython 
libs, so I guess I need to make sure to import it explicitly, rather 
than letting matplotlib do it for me, so py2app will find it.
I got this error at some point:
/usr/bin/strip: the __LINKEDIT segment does not cover the end of the 
file (can't be processed) in: 
/Users/cbarker/HAZMAT/SmallToolsSVN/phCalculator/trunk/dist/test.app/Contents/Frameworks/libncurses.5.dylib 
(for architecture i386)
But it seems to work -- is that a problem? And I don't know why I need 
ncurses anyway!
So, in summary:
with the latest py2app and removing the pytz line from the recipe, I 
have py2app working with MPL. Note that I'm not doing anything with 
time, so I don't know if there is a pytz problem or not.
-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: Gerolf Z. <ger...@go...> - 2008年03月27日 19:48:32
Hi,
Thanks for all the replies! Of course it is not directly a bug. But
awkward. This is how I was finally able to change alle fonts and the
whole layout of the plot:
fig_width_pt = 246.0 # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean # height in inches
fig_size = [fig_width,fig_height]
params = {'backend': 'ps','axes.labelsize': 10,'text.fontsize': 10,'legend.fontsize': 10,'text.usetex': True,'text.latex.preamble':["\usepackage{bm}","\usepackage{textcomp}"], 'figure.figsize': fig_size, 'font.family' : 'sans-serif', 'font.style': 'normal', 'font.weight':'normal',}
rcParams.update(params)
.......
ffont = {'family':'sans-serif','fontsize':10,'weight':'bold'}
ax1=gca()
ax1.set_xticklabels(ax1.get_xticks(),ffont)
ax1.set_yticklabels(ax1.get_yticks(),ffont)
subplots_adjust(top=1-.13)
xticks(**ffont)
yticks(**ffont)
Best regards:
 Gerolf
On Thu 27.Mar.08 14:54, Darren Dale wrote:
> On Thursday 27 March 2008 01:27:28 pm Gerolf Ziegenhain wrote:
> > More complete:
> >
> > I tried all permunations of backends. Now I stick to PS, because I use
> > matplotlib from commandline with scripts. The environment is debian/etch
> > with a current version of matplotlib (self compiled).
> >
> > Try this script
> > ********************************************
> > from pylab import *
> >
> > t = arange(0.0, 2.0, 0.01)
> > s = sin(2*pi*t)
> > plot(t, s)
> > grid(True)
> >
> > # matlab handle graphics style
> > xticklines = getp(gca(), 'xticklines')
> > yticklines = getp(gca(), 'yticklines')
> > xgridlines = getp(gca(), 'xgridlines')
> > ygridlines = getp(gca(), 'ygridlines')
> > xticklabels = getp(gca(), 'xticklabels')
> > yticklabels = getp(gca(), 'yticklabels')
> >
> > setp(xticklines, 'linewidth', 3)
> > setp(yticklines, 'linewidth', 3)
> > setp(xgridlines, 'linestyle', '-')
> > setp(ygridlines, 'linestyle', '-')
> > setp(yticklabels, 'color', 'r', fontsize='medium')
> > setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')
> >
> > savefig('axprops_demo')
> > ******************************************
> >
> > On my system the line
> > setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')
> > doesn't change the font family.
> 
> Do you use "usetex"? If you do, the mathtext is rendered using latex, and 
> latex renders mathtext in serif fonts.
> 
> Darren
> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-- 
Dipl. Phys. Gerolf Ziegenhain 
Web: http://gerolf.ziegenhain.com
Email: mai...@zi...
Fax: +49 611 18840599
Phone: +49 611 18840590
Office: Erwin-Schrödinger-Str. 46 / Room 46.332 / 67663 Kaiserslautern / Germany
Private: Klopstockstr. 21 / 65187 Wiesbaden / Germany
From: Ryan K. <rya...@gm...> - 2008年03月27日 19:00:59
I guess you could read the rcParams value that corresponds to the
screen display and set rcParams['savefig.dpi'] to that value (this
might work):
mydpi = rcParams['figure.dpi']
rcParams['savefig.dpi'] = mydpi
But that seems slightly hackish and maybe not much more elegant than
what you are currently doing with passing dpi into savefig.
FWIW,
Ryan
On Thu, Mar 27, 2008 at 1:57 PM, Christopher Barker
<Chr...@no...> wrote:
> Ryan Krauss wrote:
> > I think this line in the rc file is the trick
> >
> > #savefig.dpi : 100
>
> nope. I think all that does is set the default dpi for savefig. I don't
> want any default, I want it to use the same dpi that is being used for
> display, and I don't know ahead of time what that is, I expect it is
> system dependent.
>
> Or do you mean that if I comment out that line, it will default to the
> one already in use? In which case, I need to go figure out how to change
> that in code, rather than messing with my matplotlibrc.
>
>
>
> -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...
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Darren D. <dar...@co...> - 2008年03月27日 18:54:17
On Thursday 27 March 2008 01:27:28 pm Gerolf Ziegenhain wrote:
> More complete:
>
> I tried all permunations of backends. Now I stick to PS, because I use
> matplotlib from commandline with scripts. The environment is debian/etch
> with a current version of matplotlib (self compiled).
>
> Try this script
> ********************************************
> from pylab import *
>
> t = arange(0.0, 2.0, 0.01)
> s = sin(2*pi*t)
> plot(t, s)
> grid(True)
>
> # matlab handle graphics style
> xticklines = getp(gca(), 'xticklines')
> yticklines = getp(gca(), 'yticklines')
> xgridlines = getp(gca(), 'xgridlines')
> ygridlines = getp(gca(), 'ygridlines')
> xticklabels = getp(gca(), 'xticklabels')
> yticklabels = getp(gca(), 'yticklabels')
>
> setp(xticklines, 'linewidth', 3)
> setp(yticklines, 'linewidth', 3)
> setp(xgridlines, 'linestyle', '-')
> setp(ygridlines, 'linestyle', '-')
> setp(yticklabels, 'color', 'r', fontsize='medium')
> setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')
>
> savefig('axprops_demo')
> ******************************************
>
> On my system the line
> setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')
> doesn't change the font family.
Do you use "usetex"? If you do, the mathtext is rendered using latex, and 
latex renders mathtext in serif fonts.
Darren
From: Christopher B. <Chr...@no...> - 2008年03月27日 18:54:08
Ryan Krauss wrote:
> I think this line in the rc file is the trick
> 
> #savefig.dpi : 100
nope. I think all that does is set the default dpi for savefig. I don't 
want any default, I want it to use the same dpi that is being used for 
display, and I don't know ahead of time what that is, I expect it is 
system dependent.
Or do you mean that if I comment out that line, it will default to the 
one already in use? In which case, I need to go figure out how to change 
that in code, rather than messing with my matplotlibrc.
-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: Michael D. <md...@st...> - 2008年03月27日 18:46:12
Christopher Barker wrote:
> Michael Droettboom wrote:
> 
>> I think the real reason this wasn't done is that its tricky to do at the 
>> C level in a cross-platform way. At present it uses the regular POSIX 
>> fopen in C, which isn't really "Unicode aware".
>> 
>
> The actual error is from trying to put the filename in a std::string, 
> 
Presumably because it doesn't decode into ASCII.
> but yes, I'm sure the fopen issue is the driver. Does C++ offer anything 
> better?
> 
Not in the C++ standard library in a cross platform way, that I'm aware 
of. All three platforms (if you include Gtk, Qt etc.) have special 
Unicode-aware APIs, and each deals with things differently. The 
approach I took basically leverages all the trouble the Python core guys 
put into to make this work cross-platform.
> See the "Unicode
> 
>> filenames" section of the link below for some of the complications. 
>> Linux is particularly hard to get right:
>>
>> http://www.amk.ca/python/howto/unicode
>> 
>
> Thanks, that's a good one.
>
> > you can do the following as a workaround
> 
>> (with a performance hit from making many Python function calls):
>>
>> savefig(open(u"CrazyUnicodeFilename.png", "w"))
>> 
>
> thanks, I'll give that a try. I'm confused, though, why the many Python 
> function calls? the C++ code doesn't just grab the file pointer?
> 
No -- a while back, it was segfaulting when trying to do that (but I've 
since figured out why -- it was a reference counting problem). In 
0.91.2, it calls the "write" method on the Python object for each block 
of PNG data. SVN still supports that approach (to handle arbitrary 
Python file-like objects), but will extract the real C file handle if it 
is in fact a real file.
Mike
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Bob C. <she...@ho...> - 2008年03月27日 18:44:37
Hi all,
 
I have a application using a wxPython gui which has matplotlib figure, axes etc.... The code works fine and the display of mathtext works fine when run in python.
 
When I compile it and try to display any text it doesn't render the text at all (this can be anything from a simple letter to a more complex equation).
 
I get an output error:
 
myDir\dist\library.zip\matplotlib\mathtext.py:722: MathTextWarning: Unrecognized symbol 'y'. Substituting with a dummy symbol.
 
I added the the include "matplotlib.mathtext" as before I got an error that it didn't know what mathtext was.
 
Any ideas? I've looked on line at http://www.py2exe.org/index.cgi/MatPlotLib, and tried all they suggest but no luck so far.
 
Thanks for any ideas.
 
Cheers
 
 
my py2exe compile.py file is:
 
from distutils.core import setupimport py2exefrom distutils.core import setup# We need to import the glob module to search for all files.import globimport matplotlib
opts = { 'py2exe': { "includes" : ["matplotlib.backends.backend_wxagg", "matplotlib.figure","pylab", "numpy", "matplotlib.numerix.fft", "matplotlib.numerix.linear_algebra", "matplotlib.numerix.random_array", "matplotlib.mathtext" ], 'dll_excludes': ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll'] } }
# Looked online and tried this next line - but it doesn't compile.
#data_files=[matplotlib.get_py2exe_datafiles()]# Save matplotlib-data to mpl-data ( It is located in the matplotlib\mpl-data # folder and the compiled programs will look for it in \mpl-data# note: using matplotlib.get_mpldata_infodata_files = [(r'mpl-data', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\*.*')), # Because matplotlibrc does not have an extension, glob does not find it (at least I think that's why) # So add it manually here: (r'mpl-data', [r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\matplotlibrc']), (r'mpl-data\images',glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\images\*.*')), (r'mpl-data\fonts',glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\fonts\*.*'))]
 
setup(windows=[{"script" : "main.py"}], options=opts, data_files=data_files)
 
_________________________________________________________________
Win 100’s of Virgin Experience days with BigSnapSearch.com
http://www.bigsnapsearch.com 
From: Christopher B. <Chr...@no...> - 2008年03月27日 18:31:17
Michael Droettboom wrote:
> I think the real reason this wasn't done is that its tricky to do at the 
> C level in a cross-platform way. At present it uses the regular POSIX 
> fopen in C, which isn't really "Unicode aware".
The actual error is from trying to put the filename in a std::string, 
but yes, I'm sure the fopen issue is the driver. Does C++ offer anything 
better?
 See the "Unicode
> filenames" section of the link below for some of the complications. 
> Linux is particularly hard to get right:
> 
> http://www.amk.ca/python/howto/unicode
Thanks, that's a good one.
 > you can do the following as a workaround
> (with a performance hit from making many Python function calls):
> 
> savefig(open(u"CrazyUnicodeFilename.png", "w"))
thanks, I'll give that a try. I'm confused, though, why the many Python 
function calls? the C++ code doesn't just grab the file pointer?
Thanks,
-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: Christopher B. <Chr...@no...> - 2008年03月27日 17:34:31
It's a very good idea, when posting questions to a list like this, to 
ask not only the specific question, but also give the background, so we 
can wee what problem you are trying to solve.
sa6113 wrote:
> I use matplotlib and Backend Agg to draw a plot , I want to show this plot in
> my GUI in specific area (Plot area) ,
This is background we need. However, you've left out a key point: what 
GUI toolkit are you using? There is no such thing as a python "image", 
but each toolkit has it's own implementation, so each needs to be 
treated differently.
 I need to have the image object in
> oder to show it, so I have to convert this plot to string or array or save
> in buffer and then load it to an Image ,
If you are using any of the supported back ends: Tk, QT, wx, GTK, then 
MPL has already solved that problem for you -- see the "embedded_in**" 
examples.
If you are using something else, then take a look at the various 
back-end codes -- one of them is probably similar enough to yous to give 
you inspiration.
And yes, you can get a string or buffer object of RBG data from 
FigureCanvasAgg.
> I want to know , can I accomplish
> this without using PIL ,
You shouldn't need PIL.
-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: Gerolf Z. <zi...@rh...> - 2008年03月27日 17:27:33
More complete:
I tried all permunations of backends. Now I stick to PS, because I use
matplotlib from commandline with scripts. The environment is debian/etch
with a current version of matplotlib (self compiled).
Try this script
********************************************
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s)
grid(True)
# matlab handle graphics style
xticklines = getp(gca(), 'xticklines')
yticklines = getp(gca(), 'yticklines')
xgridlines = getp(gca(), 'xgridlines')
ygridlines = getp(gca(), 'ygridlines')
xticklabels = getp(gca(), 'xticklabels')
yticklabels = getp(gca(), 'yticklabels')
setp(xticklines, 'linewidth', 3)
setp(yticklines, 'linewidth', 3)
setp(xgridlines, 'linestyle', '-')
setp(ygridlines, 'linestyle', '-')
setp(yticklabels, 'color', 'r', fontsize='medium')
setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')
savefig('axprops_demo')
******************************************
On my system the line
 setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')
doesn't change the font family.
Best regards:
 Gerolf
-- 
Dipl. Phys. Gerolf Ziegenhain (ge...@zi...)
Private: Klopstockstrasse 21 - 65187 Wiesbaden - Germany
Office: Room 46-332 - Erwin-Schrödinger-Str.46 - TU Kaiserslautern - Germany
Web: gerolf.ziegenhain.com
Tel.: +49-611-18840590
Fax: +49-611-18840599
From: Chris W. <ch...@si...> - 2008年03月27日 17:26:43
Matthias Michler wrote:
> I'm not sure that I understand you correctly. The code I refering is the one 
> which I attached some mails ago. The following works for me:
Ah, okay, to get the problem I was having, change your script as follows:
> ---------------------------------------------------------------------------------
> from pylab import *
 > from datetime import datetime
> from time import sleep
> 
> ion() # interactive mode 'on'
> figure()
> ax = subplot(111, autoscale_on=True)
> 
> x, y = [datetime.now()], [0]
> line = plot(x, y, label="my_data")[0] 
> # get the line-object as the first element 
> # of the tuple returned by plot
> legend()
> for i in arange(30):
> x.append(datetime.now()) # append new values
> y.append(i**2)
> line.set_data(x,y) # reset data
> ax.relim() # reset axes limits
> ax.autoscale_view() # rescale axes
> draw() # redraw current figure
> sleep(0.3) # wait 0.3 seconds
> 
> ioff()
> show()
So, basically make the x axis time instead of numbers.
I think the problem is actually that the daets are quite long in their 
format. If they were rotated through 90 degress it'd likely be fine.
How would I do this?
Also, how would I get this kind of updating with bar charts or errorbars?
cheers,
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: Gerolf Z. <mai...@zi...> - 2008年03月27日 17:21:25
More complete:
I tried all permunations of backends. Now I stick to PS, because I use
matplotlib from commandline with scripts. The environment is debian/etch
with a current version of matplotlib (self compiled).
Try this script
********************************************
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s)
grid(True)
# matlab handle graphics style
xticklines = getp(gca(), 'xticklines')
yticklines = getp(gca(), 'yticklines')
xgridlines = getp(gca(), 'xgridlines')
ygridlines = getp(gca(), 'ygridlines')
xticklabels = getp(gca(), 'xticklabels')
yticklabels = getp(gca(), 'yticklabels')
setp(xticklines, 'linewidth', 3)
setp(yticklines, 'linewidth', 3)
setp(xgridlines, 'linestyle', '-')
setp(ygridlines, 'linestyle', '-')
setp(yticklabels, 'color', 'r', fontsize='medium')
setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')
savefig('axprops_demo')
******************************************
On my system the line
 setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')
doesn't change the font family.
Best regards:
 Gerolf
-- 
Dipl. Phys. Gerolf Ziegenhain (ge...@zi...)
Private: Klopstockstrasse 21 - 65187 Wiesbaden - Germany
Office: Room 46-332 - Erwin-Schrödinger-Str.46 - TU Kaiserslautern - Germany
Web: gerolf.ziegenhain.com
Tel.: +49-611-18840590
Fax: +49-611-18840599
From: Michael D. <md...@st...> - 2008年03月27日 16:58:35
Gerolf Ziegenhain wrote:
> Dear Mailinglist,
>
> Today I tried to change the fontset to sans-serif for a whole plot.
> Everything except the ticks could be adjusted. 
>
>
> This is what I tried first:
> *******************************************************
> ffont = {'size':'20','family':'sans-serif'}
> xticks(**ffont)
> *******************************************************
> 
Hmmm... This works for me. What backend are you using? Perhaps it 
isn't updating? Also, do these two lines + show() alone not work, or is 
it only in the context of something else?
Also, what platform are you on?
Mike
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Matthias M. <Mat...@gm...> - 2008年03月27日 16:51:11
Hello Chris,
On Thursday 27 March 2008 12:22, Chris Withers wrote:
> Matthias Michler wrote:
> >>> the above script leads
> >>> to a different behaviour on my system.
> >>
> >> What is that behaviour and what version of matplotlib are you using?
> >
> > I think it is the expected behaviour. The number of xtick is aproximately
> > constant and some tick get sorted out, when the xlimits are increasing.
> > I'm using matplotlib-svn r5024 on Debian etch.
>
> Hmm, do you have a code snippet to demonstrate this?
> Maybe I'm missing some vital step that causes the axis to re-calculate
> its ticks?
I'm not sure that I understand you correctly. The code I refering is the one 
which I attached some mails ago. The following works for me:
---------------------------------------------------------------------------------
from pylab import *
from time import sleep
ion() # interactive mode 'on'
figure()
ax = subplot(111, autoscale_on=True)
x, y = [0], [0]
line = plot(x, y, label="my_data")[0] 
 # get the line-object as the first element 
 # of the tuple returned by plot
legend()
for i in arange(30):
 x.append(i) # append new values
 y.append(i**2)
 line.set_data(x,y) # reset data
 ax.relim() # reset axes limits
 ax.autoscale_view() # rescale axes
 draw() # redraw current figure
 sleep(0.3) # wait 0.3 seconds
ioff()
show()
----------------------------------------------------------------------------------
And your mpltest.py works as well for me. 
best regards
Matthias
From: Gerolf Z. <zi...@rh...> - 2008年03月27日 16:42:20
Dear Mailinglist,
Today I tried to change the fontset to sans-serif for a whole plot.
Everything except the ticks could be adjusted. 
This is what I tried first:
*******************************************************
ffont = {'size':'20','family':'sans-serif'}
xticks(**ffont)
*******************************************************
No change in the font family. But I can change the size without
problems. I removed the ~/.matplotlib/FONTCACHE stuff as described
here(2).
Following (1) I tried again to change the font using
*******************************************************
import pylab
pylab.figure()
ax = pylab.axes()
ax.plot(pylab.arange(10))
xlabels = ax.get_xticklabels()
xlabel0 = xlabels[0] # one of the xtick
labels
xlabel0.get_fontsize()
xlabel0.set_fontsize(20)
pylab.show() 
*******************************************************
Again nothing changed.
Using ipython I got this:
*******************************************************
In [192]: xlabels[0].get_fontname()
Out[192]: 'Bitstream Vera Serif, New Century Schoolbook, serif'
In [195]: xlabels[0].set_family("sans-serif")
In [196]: xlabels[0].get_fontname()
Out[196]: 'Bitstream Vera Sans, Lucida Grande, Verdana, sans-serif'
In [197]: show()
*******************************************************
Summary:
It appears to me like I can change the default fontfamily, but somehow
there is no change in the output. 
What could be the problem?
Best regards:
 Gerolf
(1) http://www.nabble.com/axes-numbers-font-size-td14459877.html
(2) http://matplotlib.sourceforge.net/faq.html#FONTMISSING
-- 
Dipl. Phys. Gerolf Ziegenhain 
Web: http://gerolf.ziegenhain.com
Email: mai...@zi...
Fax: +49 611 18840599
Phone: +49 611 18840590
Office: Erwin-Schrödinger-Str. 46 / Room 46.332 / 67663 Kaiserslautern / Germany
Private: Klopstockstr. 21 / 65187 Wiesbaden / Germany
From: Chris W. <ch...@si...> - 2008年03月27日 16:01:16
Matthias Michler wrote:
>>> the above script leads
>>> to a different behaviour on my system.
>> What is that behaviour and what version of matplotlib are you using?
> 
> I think it is the expected behaviour. The number of xtick is aproximately 
> constant and some tick get sorted out, when the xlimits are increasing.
> I'm using matplotlib-svn r5024 on Debian etch.
Hmm, do you have a code snippet to demonstrate this?
Maybe I'm missing some vital step that causes the axis to re-calculate 
its ticks?
> sorry. I have no idea where this problems comes from. I have seen that using 
> idle and the latest release of matplotlib on and winxp, but I can't reproduce 
> it on my linux system.
*sigh* ;-)
Chris
-- 
Simplistix - Content Management, Zope & Python Consulting
 - http://www.simplistix.co.uk
From: KURT P. <pet...@ms...> - 2008年03月27日 15:16:54
And, before someone asks, "Why are you using "h" and this line:
 h= [seg[0]*0.000278,seg[1]*0.000278]
 ax.annotate(seqnum[nshape],h)",
I was using this, instead, but tried to experiment with things to try to 
make things work right:
 ax.annotate(seqnum[nshape],seg)
.
I usually don't "give up" and post a question unless I've tried a myriad of 
things, and unfortunately those things sometimes show up in the example 
code.
Regards,
Kurt
From: KURT P. <pet...@ms...> - 2008年03月27日 14:59:40
OK Jeff, Thanks for your help on the previous question - I had been playing 
with different projections and resolutions, so that's why the comments 
didn't match the actual settings in the procedure calls. Now for a "real" 
problem:
I'm trying to plot the cities from this web site: 
http://nationalatlas.gov/metadata/citiesx020.faq.html
using that shapefile, which uses points, not polygons (it took a long time 
to figure out that difference from the example of fillstates.py).
http://nationalatlas.gov/atlasftp.html?openChapters=chpref#chpref
While I think I'm loading everything and displaying everything correctly, 
the values are not plotting right, nor do they seem realistic.
For instance the point values look like this (which really can't be right):
Shape num Fairbanks, coords=(42082.855349492747, 5336578.2660309337)
Shape num Anchorage, coords=(-442294.67146861833, 5031412.4918638617)
print shp_info - the second value shows to use points not polys:
(35432, 1, [-174.20294189453125, 17.711706161499023, 0.0, 0.0], 
[178.87460327148437, 71.290138244628906, 0.0, 0.0])
Dictionaries:
['STATE_FIPS', 'NAME', 'POP_2000', 'FEATURE', 'COUNTY', 'STATE', 'FIPS', 
'CITIESX020', 'FIPS55', 'DISPLAY', 'POP_RANGE']
STATE_FIPS = 02, NAME = Anchorage, POP_2000=260283, FEATURE = County Seat, 
COUNTY=Anchorage Borough, STATE=AK, FIPS=02020, CITIESX020 = 194, 
FIPS55=03000, DISPLAY=0, POP_RANGE=250,000 - 499,999
Here's the code:
===============
import pylab as p
import numpy
from matplotlib.toolkits.basemap import Basemap as Basemap
from matplotlib.colors import rgb2hex
from matplotlib.patches import Polygon
# Lambert Conformal map of lower 48 states.
# create new figure
fig=p.figure()
m1 = Basemap(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,\
 projection='lcc',lat_1=33,lat_2=45,lon_0=-95,resolution='c')
shp_info = 
m1.readshapefile(r'C:\Python25\Lib\basemap-0.9.9.1\examples\citiesx020','states',drawbounds=True)
ax=p.gca()
#define SHPT_POINT 1 Points
#define SHPT_ARC 3 Arcs (Polylines, possible in parts)
#define SHPT_POLYGON 5 Polygons (possible in parts)
#define SHPT_MULTIPOINT 8 MultiPoint (related points)
print shp_info
print m1.states_info[0].keys()
seqnum={}
criteriatodisplay=[]
ii=0
for shapedict in m1.states_info:
 if int(shapedict['POP_2000'])>100000:
#'STATE_FIPS', 'NAME', 'POP_2000', 'FEATURE', 'COUNTY', 'STATE', 'FIPS', 
'CITIESX020', 'FIPS55', 'DISPLAY', 'POP_RANGE']
 print 'STATE_FIPS = %s, NAME = %s, POP_2000=%s, FEATURE = %s, 
COUNTY=%s, STATE=%s, FIPS=%s, CITIESX020 = %s, FIPS55=%s, DISPLAY=%s, 
POP_RANGE=%s' %\
 (str(shapedict['STATE_FIPS']), str(shapedict['NAME']), 
str(shapedict['POP_2000']), str(shapedict['FEATURE']), 
str(shapedict['COUNTY']), str(shapedict['STATE']), str(shapedict['FIPS']), 
str(shapedict['CITIESX020']), str(shapedict['FIPS55']), 
str(shapedict['DISPLAY']), str(shapedict['POP_RANGE']))
 seqnum[shapedict['CITIESX020']]=shapedict['NAME']
 criteriatodisplay.append(shapedict['CITIESX020'])
 ii+=1
print ii
for nshape,seg in enumerate(m1.states):
 if nshape in criteriatodisplay:
 print 'Shape num %s, coords=%s' % (seqnum[nshape], seg)
 h= [seg[0]*0.000278,seg[1]*0.000278]
 ax.annotate(seqnum[nshape],h)
m1.drawcoastlines()
m1.fillcontinents()
m1.drawcountries()
m1.drawstates()
m1.drawparallels(numpy.arange(25,65,4),labels=[1,0,0,0])
m1.drawmeridians(numpy.arange(-120,-40,4),labels=[0,0,0,1])
p.title('Test Cities')
p.show()
=============
Regards,
Kurt
From: Jeff W. <js...@fa...> - 2008年03月27日 14:46:13
KURT PETERS wrote:
> I'm trying what I thought was a simple test and getting "bad" results. I am 
> taking some lat long coords, and feeding it into a map. The conversion is 
> not giving "real" values that can be plotted on a map (and actually produces 
> an error when I use annotate).
> I'm including the simple code and the output:
> 
>>>>>>>>>> CODE<<<<<<<<<<<<<<<
>>>>>>>>>> 
> import pylab as p
> import numpy
> from matplotlib.toolkits.basemap import Basemap as Basemap
> from matplotlib.colors import rgb2hex
> from matplotlib.patches import Polygon
>
> # Lambert Conformal map of lower 48 states.
> # create new figure
> fig=p.figure()
> m1 = Basemap(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,\
> 
> projection='ortho',lat_1=33,lat_2=45,lon_0=-95,lat_0=40,resolution='c')
>
>
> #COS
> #D + M/60 + S/3600
> COSLat=38+56.0/60.0+0.013
> COSLon=-1*(104+48.0/60.0)
> WASHLat=38+53.0/60.0+23.0/3600.0
> WASHLon=-1*(77+32.0/3600.0)
>
> print COSLat
> x, y = m1(COSLat,COSLon)
> print 'x =%f, y=%f' % (x,y)
>
> m1.plot([x],[y],'ko')
> ax=p.gca()
> ax.annotate('COS1',(COSLat,COSLon))
> #ax.annotate('COS2',(x,y))
> ax.annotate('Wash1',(WASHLat,WASHLon))
> x, y = m1(WASHLat,WASHLon)
> #ax.annotate('Wash2',(x,y))
>
> m1.drawcoastlines()
> m1.fillcontinents()
> m1.drawcountries()
> m1.drawstates()
> m1.drawparallels(numpy.arange(25,65,4),labels=[1,0,0,0])
> m1.drawmeridians(numpy.arange(-120,-40,4),labels=[0,0,0,1])
> p.title('full resolution')
> p.show()
> <<<<<<<<<Output>>>>>>>>>>>
> 38.9463333333
> x =1000000000000000000000000000000.000000, 
> y=1000000000000000000000000000000.000000
>
> Regards,
> Kurt
>
> 
Kurt: If you want the Lambert conformal projection, you should use 
projection='lcc', not 'ortho'. 
Nevertheless, your example works for me if I change the order of the 
arguments passed to the Basemap instance to
x, y = m1(COSLon,COSLat)
x, y = m1(WASHLon,WASHLat)
Note, longitude goes first.
Also, if you want 'full resolution' coastlines, use resolution='h'.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328
From: Michael D. <md...@st...> - 2008年03月27日 14:43:53
I think the real reason this wasn't done is that its tricky to do at the 
C level in a cross-platform way. At present it uses the regular POSIX 
fopen in C, which isn't really "Unicode aware". See the "Unicode 
filenames" section of the link below for some of the complications. 
Linux is particularly hard to get right:
http://www.amk.ca/python/howto/unicode
However, the Python runtime does take care of many of these details in a 
(mostly) reasonable way. I think the easiest solution is to open the 
file on the Python side (rather than using POSIX fopen in C as we do 
now), and pass the file descriptor itself over to C. There was a bug in 
extracting the file descriptor from a Python file object in earlier 
versions of mpl, so it was removed a while ago, but I think I have it 
working again.
This should now be fixed on r5025 (branch) and r5026 (trunk)
Note that if you are running 0.91.2 (and not SVN, where this was 
subsequently broken in r4874), you can do the following as a workaround 
(with a performance hit from making many Python function calls):
 savefig(open(u"CrazyUnicodeFilename.png", "w"))
On a related note -- there is still an issue where fonts with Unicode 
paths can not be loaded. That can hopefully be addressed in a similar 
manner, but there are a few more code paths to fix up there.
Mike
Christopher Barker wrote:
> Hi all,
>
> I'm writing a little MPL embedded in wxPython app, and just ran into this:
>
> Traceback (most recent call last):
> ...
> ...
> "..../matplotlib-0.91.2-py2.5-macosx-10.3-fat.egg/matplotlib/backends/backend_agg.py", 
>
> line 397, in print_png
> self.get_renderer()._renderer.write_png(filename, 
> self.figure.dpi.get())
> TypeError: cannot return std::string from Unicode object
>
> As soon as I saw it, I knew what happened: I'm running the unicode 
> version of wxPython, so the filename I got back from a SaveFile Dialog 
> is in unicode. Now, it's easy enough for me to turn that into a string 
> for now, but as more and more file systems are implemented in unicode, 
> it might be nice if we could use unicode file names with MPL.
>
> Are there any plans along these lines? Or are we just going to have to 
> wait for py3k?
>
> -CHB
>
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: KURT P. <pet...@ms...> - 2008年03月27日 14:35:13
Forget it. I was putting lat/long instead of long/lat.
Regards,
Kurt
From: KURT P. <pet...@ms...> - 2008年03月27日 14:29:27
I'm trying what I thought was a simple test and getting "bad" results. I am 
taking some lat long coords, and feeding it into a map. The conversion is 
not giving "real" values that can be plotted on a map (and actually produces 
an error when I use annotate).
I'm including the simple code and the output:
>>>>>>>>>CODE<<<<<<<<<<<<<<<
import pylab as p
import numpy
from matplotlib.toolkits.basemap import Basemap as Basemap
from matplotlib.colors import rgb2hex
from matplotlib.patches import Polygon
# Lambert Conformal map of lower 48 states.
# create new figure
fig=p.figure()
m1 = Basemap(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,\
 
projection='ortho',lat_1=33,lat_2=45,lon_0=-95,lat_0=40,resolution='c')
#COS
#D + M/60 + S/3600
COSLat=38+56.0/60.0+0.013
COSLon=-1*(104+48.0/60.0)
WASHLat=38+53.0/60.0+23.0/3600.0
WASHLon=-1*(77+32.0/3600.0)
print COSLat
x, y = m1(COSLat,COSLon)
print 'x =%f, y=%f' % (x,y)
m1.plot([x],[y],'ko')
ax=p.gca()
ax.annotate('COS1',(COSLat,COSLon))
#ax.annotate('COS2',(x,y))
ax.annotate('Wash1',(WASHLat,WASHLon))
x, y = m1(WASHLat,WASHLon)
#ax.annotate('Wash2',(x,y))
m1.drawcoastlines()
m1.fillcontinents()
m1.drawcountries()
m1.drawstates()
m1.drawparallels(numpy.arange(25,65,4),labels=[1,0,0,0])
m1.drawmeridians(numpy.arange(-120,-40,4),labels=[0,0,0,1])
p.title('full resolution')
p.show()
<<<<<<<<<Output>>>>>>>>>>>
38.9463333333
x =1000000000000000000000000000000.000000, 
y=1000000000000000000000000000000.000000
Regards,
Kurt
From: Anthony F. <ant...@gm...> - 2008年03月27日 14:19:15
On Wed, Mar 26, 2008 at 10:38 PM, sa6113 <s.p...@gm...> wrote:
>
> I use matplotlib and Backend Agg to draw a plot , I want to show this plot in
> my GUI in specific area (Plot area) , I need to have the image object in
[snip]
> Is it clear?
Not to me :)
Do you mean that you've already created a plot and just want to show
it in your GUI?
What GUI toolkit are you using? You may want to look in the various
embedding_in_*.py examples.
A>
From: Vsevolod K. <vse...@gm...> - 2008年03月27日 10:16:53
Dear matplotlib
I have a newbie question (I am new to python, migrating from Matlab). Just
like the subject suggests, I need to display an image X stored in a matrix
(well, a 2D numpy array in fact) versus the coordinates specified by arrays
x and y. Further, it would be nice if mouse position was returned in terms
of those coordinates as well, but that's just for a nicety - I can map it
myself. But main thing is I failed to find the way to get the image
versuscoordinates in imshow() and figimage(). I also failed to find the
answer in this forum.
Hence I ask for any suggestions.
-- 
View this message in context: http://www.nabble.com/does-matplotlib-have-an-analog-to-imagesc%28x%2Cy%2CX%29-of-Matlab--tp16323613p16323613.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Matthias M. <Mat...@gm...> - 2008年03月27日 08:32:14
On Wednesday 26 March 2008 19:39, Chris Withers wrote:
> Matthias Michler wrote:
> >> My x-axis is time, and as new points are plotted, even though I'm
> >> following the above recipe pretty closely, the x-tick spacing isn't
> >> getting sorted out, so I end up with just a jumble as the tick labels
> >> for the x-axis. Do you know why this might be?
> >
> > I'm not sure I understand correctly, but if the number of xticks
> > increases dramatically (nobody could see the individual ticks),
>
> Indeed, it looks like the Tick spacing is staying as it was when the
> first point was plotted, so when hundreds more points are plotted, I
> just get a jumble of labels on the x-axis.
>
> > the above script leads
> > to a different behaviour on my system.
>
> What is that behaviour and what version of matplotlib are you using?
I think it is the expected behaviour. The number of xtick is aproximately 
constant and some tick get sorted out, when the xlimits are increasing.
I'm using matplotlib-svn r5024 on Debian etch.
> >> Shame I get that horrible exception when I do close the plot window,
> >> wish I knew how to make it stop :-S
> >
> > I don't know which exception you refer to, but sometimes if gives
> > problems if the interactive mode wasn't switched off ("ioff()") before
> > the scripts ends or "show()" is called.
>
> If I run the attached script, and hit Ctrl-C in the DOS box running it,
> I get:
>
> C:\>python mpltest.py
> Traceback (most recent call last):
> File "mpltest.py", line 3, in <module>
> show()
> File
> "C:\Python25\Lib\site-packages\matplotlib\backends\backend_tkagg.py", li
> e 76, in show
> Tk.mainloop()
> File "C:\Python25\lib\lib-tk\Tkinter.py", line 328, in mainloop
> _default_root.tk.mainloop(n)
> KeyboardInterrupt
> Fatal Python error: PyEval_RestoreThread: NULL tstate
>
> This application has requested the Runtime to terminate it in an unusual
> way.
> Please contact the application's support team for more information.
>
> I've had a similar error when I hit the red cross in the corner of the
> window with other scripts, although not this one :-S
sorry. I have no idea where this problems comes from. I have seen that using 
idle and the latest release of matplotlib on and winxp, but I can't reproduce 
it on my linux system.
Matthias

Showing results of 29

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