SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Johan G. <joh...@gm...> - 2009年10月30日 09:40:17
Hello List,
I am so far happy with the output form matplotlib, but I recently 
started annotating my plots, and when saving to png-format, the 
annotations do not look very nice. When saving to eps format, I do not 
see the same problems.
Saving to eps and converting to png seems to be a good workaround for me.
The problem is that the letters in the same word (on the same line) are 
not aligned, some are drawn to far up or down.
png and eps figures are attached. Example script and version number 
(0.99.0) below.
Am I misusing matplotlib? Is this a bug?
Regards
johan
Minimal example:
-----------------------
import matplotlib.pyplot as plt
import numpy as np
plt.figure()
x = [0]
plt.plot(x, x)
plt.annotate("units are important, 7ドル.64358,ドル 
$\\frac{\mathrm{k}\mathrm{m}}{\mathrm{s^2}}$",
 xy = (0,0),
 xycoords = "data",
 xytext = (0.2, 0.6),
 textcoords = "figure fraction",
 arrowprops = dict(arrowstyle = "->",
 connectionstyle = "arc"))
plt.savefig("pyplot_text.png")
plt.savefig("pyplot_text.eps")
plt.show()
-----------------------
Expected result: An empty plot with a nice annotation on screen, in a 
png-file, and in an eps-file
Result: Empty plots with annotation displaying differently in the three 
cases. In the png file, the letters u and r and the digit 7 appear 
slightly above the correct position, and the m in the unit km appears 
slightly below the correct position. In the screen output, the m is 
correct, but the u and r show the same problem as in the png file. In 
the eps file, all seems to be well.
My os is debian (testing), and I obtain matplotlib and all related 
software from the debian repositories.
johan@johan-laptop:~$ uname -a
Linux johan-laptop 2.6.30-2-amd64 #1 SMP Fri Sep 25 22:16:56 UTC 2009 
x86_64 GNU/Linux
johan@johan-laptop:~$ python -c "import matplotlib; print 
matplotlib.__version__"
0.99.0
From: Jae-Joon L. <lee...@gm...> - 2009年10月30日 18:42:59
I don't see such problem in my installations.
I may be wrong but It seems to me that it is a font issue (I believe
you're not using usetex mode).
Can you try to use other fonts?
For example, my current installation picks up the following font (Vera Serif?).
In [10]: matplotlib.font_manager.findfont(None)
Out[10]: '/astro/research/jul27/local/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/VeraSe.ttf'
Regards,
-JJ
2009年10月30日 Johan Grönqvist <joh...@gm...>:
> Hello List,
>
> I am so far happy with the output form matplotlib, but I recently started
> annotating my plots, and when saving to png-format, the annotations do not
> look very nice. When saving to eps format, I do not see the same problems.
>
> Saving to eps and converting to png seems to be a good workaround for me.
>
> The problem is that the letters in the same word (on the same line) are not
> aligned, some are drawn to far up or down.
>
> png and eps figures are attached. Example script and version number (0.99.0)
> below.
>
> Am I misusing matplotlib? Is this a bug?
>
>
> Regards
>
> johan
>
>
>
>
>
>
>
>
> Minimal example:
> -----------------------
> import matplotlib.pyplot as plt
> import numpy as np
>
> plt.figure()
>
> x = [0]
> plt.plot(x, x)
>
> plt.annotate("units are important, 7ドル.64358,ドル
> $\\frac{\mathrm{k}\mathrm{m}}{\mathrm{s^2}}$",
>       xy = (0,0),
>       xycoords = "data",
>       xytext = (0.2, 0.6),
>       textcoords = "figure fraction",
>       arrowprops = dict(arrowstyle = "->",
>                connectionstyle = "arc"))
>
>
> plt.savefig("pyplot_text.png")
> plt.savefig("pyplot_text.eps")
> plt.show()
> -----------------------
>
>
> Expected result: An empty plot with a nice annotation on screen, in a
> png-file, and in an eps-file
>
> Result: Empty plots with annotation displaying differently in the three
> cases. In the png file, the letters u and r and the digit 7 appear slightly
> above the correct position, and the m in the unit km appears slightly below
> the correct position. In the screen output, the m is correct, but the u and
> r show the same problem as in the png file. In the eps file, all seems to be
> well.
>
> My os is debian (testing), and I obtain matplotlib and all related software
> from the debian repositories.
>
> johan@johan-laptop:~$ uname -a
> Linux johan-laptop 2.6.30-2-amd64 #1 SMP Fri Sep 25 22:16:56 UTC 2009 x86_64
> GNU/Linux
> johan@johan-laptop:~$ python -c "import matplotlib; print
> matplotlib.__version__"
> 0.99.0
>
>
>
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
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 によって変換されたページ (->オリジナル) /