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




Showing 3 results of 3

From: George N. <ag...@no...> - 2005年05月22日 22:01:11
Thought I'd summarize my experiences. They may result from a messed up =20=
installation, but could be useful for others -- Bradley Minch, using =20
10.2.8, seems to have had my initial problem, #I below.
Excuse the overlong email here.
Many thanks to Darren Dale for helping me out.
Setup:
matplotlib 0.80, ipython 0.6.13, readline.so [from =20
www.pycs.net/bbum/2004/1/21/readline.so.gz]
 zlib, libpng, tk_inter8.4, freetype 2.1.9 [produces =20
libfreetype.6.3.7.dylib], wx-2.6-mac-unicode,
 standard Panther Apple Python 2.3, updated to MacPython,
 scipy 0.3.2 [from =20
http://cbis.anu.edu.au/misc/SciPy_complete-0.3.2.mpkg.zip]
Numeric 23.1, OS X 10.3.9
Running with TkAgg backend set in .matplotlibrc
1. Original problem:
First time I did
from pylab import * (or ipython -pylab)
got error while font_manager was trying to build the ttffont.cache...
 =C2=A0 File =20
"/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-=20=
packages/matplotlib/font_manager.py", line 347, in ttfFontProperty
 =C2=A0=C2=A0=C2=A0 size =3D str(float(font.get_fontsize()))
 AttributeError: get_fontsize
Now, when building the ttf cache, font_manager searches for TrueType =20
fonts.
1. in the matplotlib data directory =20
/System/Library/Frameworks/Python.framework/Versions/2.3/share/=20
matplotlib
2. In the normal Mac places
/Library/Fonts/, /System/Library/Fonts,/Network/Library/Fonts, =20
~/Library/Fonts
Tracked this problem down to the font VT102Font that I had in =20
~/Library/Fonts.
Moved VT102Font to (new directory) ~/SuspectFonts off the font path.
Problem 1 solved! from pylab import * now happily built a =20
~/.ttffont.cache for me.
2. Next problem -- absurdly large, corrupted, PS files.
Ran this script that produces simple plots, with axes labelled (by =20
default) with sans-serif numbers.
dt =3D 0.01
t =3D arange(0,10,dt)
subplot(211)
s =3D sin(t)
plot(t,s)
subplot(212)
c =3D cos(t)
plot(t,c)
savefig('/Users/agn/sincos.png')
 -- produced a nice file ~28KB in size
savefig('/Users/agn/sincos.ps')
 -- produced a file of 4.6MB.
 Trying to view this file using Apple preview, or converting it to pdf =20=
with ps2pdf (ps2pdf13, v1.3, 21Feb2002) or Apple pstopdf gave an error. =20=
E.g. ps2pdf sincos.ps gave:
Error: /invalidfont in -dict-
Operand stack:
 LucidaGrande --dict:10/14(L)-- Font LucidaGrande =20
--dict:10/14(L)-- LucidaGrande
Darren Dale sorted me out here. The default sans-serif font used to =20
label the axes is the first font in the san-serif line (about line 113) =20=
in the .matplotlibrc startup file. The default .matplotlibrc gives =20
LucidaGrande as that default font. LucidaGrande.dfont is an Apple =20
standard font living in /System/Library/Fonts.
He suggested that I put Bitstream Vera Sans as the first font on the =20=
san-serif line in .matplotlibrc, so that this font, which comes with =20
matplotlib, and lives in =20
/System/Library/Frameworks/Python.framework/Versions/2.3/share/=20
matplotlib is used as the default sans-serif font instead.
Problem 2 solved. savefig('/Users/agn/sincos.ps') now gives a 176 KB =20
ps, that reduces to a 36KB pdf. Perfectly OK now.
Suspected same problem would arise for other families, so put Bitstream =20=
Vera Serif as the default serif font, & Bitstream Vera Sans Mono as =20
the default monospace font.
3. John Hunter suggested that problem 2 might be solved if I were to =20
modify line 180 of .matplotlibrc to set
 ps.useafm : True
This should give smaller Ps files at the cost of breaking mathtext =20
(which incidentally *does* (almost completely) work for me with =20
ps.useafm : False).
Unfortunately, setting ps.useafm true doesn't work for me. Now if =20
ps.useafm is True, font_manager only makes a cache -- .afmfont.cache =20=
-- when you first try to save to PS. I have at present the problem that =20=
font_manager is falling over when trying to make this cache. One of the =20=
Chinese-type opentype (.otf) fonts --- =
/System/Library/Fonts/=E3=83=92=E3=83=A9=E3=82=AD=E3=82=99=E3=83=8E=E6=98=8E=
=E6=9C=9D =20
Pro W3.otf -- or in hex
/System/Library/Fonts/=20
\xe3\x83\x92\xe3\x83\xa9\xe3\x82\xad\xe3\x82\x99\xe3\x83\x8e\xe6\x98\x8e=20=
\xe6\x9c\x9d Pro W3.otf
causes an infinite loop with 'Key error converting in AFM' in afm.py, =20=
when trying to parse the header.
Quite a few fonts are in 'seen', --
{'pbkd8a.afm': 1, 'pagd8a.afm': 1, 'pbkl8a.afm': 1, 'ptmri8a.afm': 1, =20=
'pncb8a.afm': 1, 'phvbo8a.afm': 1, 'phvb8an.afm': 1, 'phvro8an.afm': 1, =20=
'ptmb8a.afm': 1, 'pcrro8a.afm': 1, 'pcrb8a.afm': 1, 'pplr8a.afm': 1, =20
'pzdr.afm': 1, 'cmsy10.afm': 1, 'phvlo8a.afm': 1, 'cmr10.afm': 1, =20
'phvb8a.afm': 1, 'phvl8a.afm': 1, 'pncri8a.afm': 1, 'pagdo8a.afm': 1, =20=
'putri8a.afm': 1, 'pzcmi8a.afm': 1, 'ptmbi8a.afm': 1, 'phvro8a.afm': 1, =20=
'putr8a.afm': 1, 'phvbo8an.afm': 1, 'pcrr8a.afm': 1, 'putbi8a.afm': 1, =20=
'pcrbo8a.afm': 1, 'cmtt10.afm': 1, 'pplb8a.afm': 1, 'pbkdi8a.afm': 1, =20=
'pagk8a.afm': 1, 'pncr8a.afm': 1, 'putb8a.afm': 1, 'psyr.afm': 1, =20
'pagko8a.afm': 1, 'pplbi8a.afm': 1, 'pbkli8a.afm': 1, 'pncbi8a.afm': 1, =20=
'cmmi10.afm': 1, 'ptmr8a.afm': 1, 'pplri8a.afm': 1, 'cmex10.afm': 1, =20
'phvr8a.afm': 1, =20
'\xe3\x83\x92\xe3\x83\xa9\xe3\x82\xad\xe3\x82\x99\xe3\x83\x8e\xe6\x98\x8=20=
e\xe6\x9c\x9d Pro W3.otf': 1, 'phvr8an.afm': 1}
so have presumably been successfully parsed, except for this .otf font.
Haven't sorted this problem out yet. I suppose I could try removing the =20=
East Asian fonts from the system folder, or changing font_manager so it =20=
does not read them in.
4. Conclusion: For me, the only fonts that work are the BitStream Vera =20=
Fonts supplied with matplotlib. Not ideal, because they do do not =20
include italic, cursive, or fantasy fonts (although they do include an =20=
*oblique* sans serif font). But this is sufficient to make matplotlib =20=
work for most practical purposes, especially as mathtext does work =20
(though ps2pdf can't convert the ps fonts to pdf; Apple pstopdf (used =20=
by Preview) must be used)
Again, many thanks to Darren Dale and also to John Hunter and Fernando =20=
Perez for their replies.
George Nurser.
From: John H. <jdh...@ac...> - 2005年05月22日 00:53:55
>>>>> "Ryan" == Ryan Krauss <rya...@co...> writes:
 Ryan> Setting the pad in the .matplotlibrc file was an excellent
 Ryan> solution for me. And being able to set all my font
 Ryan> preferences there is a great feature that I don't think
 Ryan> Matlab has. One of the first things I needed to do in Matlab
 Ryan> was write a script that formatted my figures the way I
 Ryan> liked. I assumed I needed to do the same thing in mpl, but
 Ryan> not so. Good Stuff!
As a long time matlab user, I grew tired of all the arcane commands
you have to execute to customize the figure. So I tried to make the
most common stuff configurable in the rc file. One feature I use a lot
is directory level customization. mpl looks in the current directory
first for the rc file, then HOME and then in the site locations.
Typically, I want different defaults for the web, for publication and
for the screen, and use directory specific rc file for these. See
also the "rc" command, for changing the defaults on a per script
basis...
JDH
From: Ryan K. <rya...@co...> - 2005年05月22日 00:45:00
Setting the pad in the .matplotlibrc file was an excellent solution for 
me. And being able to set all my font preferences there is a great 
feature that I don't think Matlab has. One of the first things I needed 
to do in Matlab was write a script that formatted my figures the way I 
liked. I assumed I needed to do the same thing in mpl, but not so. Good 
Stuff!
Ryan
John Hunter wrote:
>>>>>>"Ryan" == Ryan Krauss <rya...@co...> writes:
>>>>>> 
>>>>>>
>
> Ryan> I have a question about tick formatting. I have a semilogx
> Ryan> plot and if I resize the xticks using locs , labels = xticks
> Ryan> () set(labels , size=ticksize) I like the size and the font,
> Ryan> but the exponents (10^0) run into the axis.
>
>The reasons for are complicated and have to do with an optimization to
>make exponential ticking faster, and I won't go into them right now.
>Suffice it to say that it is a bug, but there may be a workaround
>
>Do any of the suggestions here help?
>
> http://matplotlib.sourceforge.net/faq.html#TEXTOVERLAP
>
>Note you can also control the "pad" in points of the offset of the
>ticks from the xaxis
>
> ticks = ax.xaxis.get_major_ticks()
> for tick in ticks:
> tick.set_pad(6)
>
>or if you prefer
>
> set(ax.xaxis.get_major_ticks(), pad=6)
>
>The default pad is controlled by an rc parameter
>
> tick.major.pad : 4 # distance to major tick label in points
> tick.minor.pad : 4 # distance to the minor tick label in points
>
>See http://matplotlib.sf.net/.matplotlibrc
>
>JDH
>
> 
>

Showing 3 results of 3

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