Hello,
Is there a way to color words differently in a label or title, for example:
ylabel(“measurement 1 (in red color)” , “measurement 2 (in blue color)”) to match with the plotted line colors?
Thanks.
···
–
Gökhan
Hello,
Is there a way to color words differently in a label or title, for example:
ylabel(“measurement 1 (in red color)” , “measurement 2 (in blue color)”) to match with the plotted line colors?
Thanks.
–
Gökhan
Hi Gökhan,
Do you have usetex=True set? If so, have you tried the LaTeX command sequence \color{red}{Red text goes here} ?
Regards,
– Damon
Damon McDougall
Mathematics Institute
University of Warwick
Coventry
CV4 7AL
d.mcdougall@…831…
On 11 Jan 2010, at 05:48, Gökhan Sever wrote:
Hello,
Is there a way to color words differently in a label or title, for example:
ylabel(“measurement 1 (in red color)” , “measurement 2 (in blue color)”) to match with the plotted line colors?
Thanks.
–
Gökhan
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon’s best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev _______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
Gökhan Sever wrote:
Hello,
Is there a way to color words differently in a label or title, for example:
ylabel("measurement 1 (in red color)" , "measurement 2 (in blue color)") to match with the plotted line colors?
Thanks.
--
Gökhan
Gökhan:
ylabel('measurement 1',color='r')
ylabel('measurement 2',color='b')
-Jeff
This seems like the solution. However when I try:
I[1]: plt.plot(range(10))
I[2]: plt.ylabel(r"{\color{red} a red text}")
It doesn’t function and produce an ugly set of error messages:
I[3]: ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: (‘EOF in multi-line statement’, (573, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: (‘EOF in multi-line statement’, (573, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: (‘EOF in multi-line statement’, (573, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: (‘EOF in multi-line statement’, (573, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: (‘EOF in multi-line statement’, (566, 0))
RuntimeError Traceback (most recent call last)
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_qt4.pyc in resizeEvent(self, event)
167 hinch = h/dpival
168 self.figure.set_size_inches( winch, hinch )
→ 169 self.draw()
170 self.update()
171 QtGui.QWidget.resizeEvent(self, event)
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_qt4agg.pyc in draw(self)
128 if DEBUG: print “FigureCanvasQtAgg.draw”, self
129 self.replot = True
→ 130 FigureCanvasAgg.draw(self)
131 self.update()
132
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_agg.pyc in draw(self)
386
387 self.renderer = self.get_renderer()
→ 388 self.figure.draw(self.renderer)
389
390 def get_renderer(self):
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
—> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/figure.pyc in draw(self, renderer)
800 dsu.sort(key=itemgetter(0))
801 for zorder, func, args in dsu:
→ 802 func(*args)
803
804 renderer.close_group(‘figure’)
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
—> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axes.pyc in draw(self, renderer, inframe)
1755
1756 for zorder, a in dsu:
→ 1757 a.draw(renderer)
1758
1759 renderer.close_group(‘axes’)
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
—> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axis.pyc in draw(self, renderer, *args, **kwargs)
819 self._update_label_position(ticklabelBoxes, ticklabelBoxes2)
820
→ 821 self.label.draw(renderer)
822
823 self._update_offset_text_position(ticklabelBoxes, ticklabelBoxes2)
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
—> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/text.pyc in draw(self, renderer)
547 renderer.open_group(‘text’, self.get_gid())
548
→ 549 bbox, info = self._get_layout(renderer)
550 trans = self.get_transform()
551
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/text.pyc in _get_layout(self, renderer)
303 w, h, d = get_text_width_height_descent(clean_line,
304 self._fontproperties,
→ 305 ismath=ismath)
306 if baseline is None:
307 baseline = h - d
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_agg.pyc in get_text_width_height_descent(self, s, prop, ismath)
169 fontsize = prop.get_size_in_points()
170 w, h, d = texmanager.get_text_width_height_descent(s, fontsize,
→ 171 renderer=self)
172 return w, h, d
173
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/texmanager.pyc in get_text_width_height_descent(self, tex, fontsize, renderer)
599 else:
600 # use dviread. It sometimes returns a wrong descent.
→ 601 dvifile = self.make_dvi(tex, fontsize)
602 dvi = dviread.Dvi(dvifile, 72*dpi_fraction)
603 page = iter(dvi).next()
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/texmanager.pyc in make_dvi(self, tex, fontsize)
369 if exit_status or not exists:
370 raise RuntimeError((‘LaTeX was not able to process the following
→ 371 string:\n%s\nHere is the full report generated by LaTeX: \n\n’% repr(tex)) + report)
372 else: mpl.verbose.report(report, ‘debug’)
373 for fname in glob.glob(basefile+‘*’):
RuntimeError: LaTeX was not able to process the following string:
‘{\color{red} a red text}’
Here is the full report generated by LaTeX:
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
%&-line parsing enabled.
entering extended mode
(./f5e3ddba2ab4bf5147d4e32e96deb043.tex
LaTeX2e <2005/12/01>
Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, arabic, basque, bulgarian, coptic, welsh, czech, slovak, german, ng
erman, danish, esperanto, spanish, catalan, galician, estonian, farsi, finnish,
french, greek, monogreek, ancientgreek, croatian, hungarian, interlingua, ibyc
us, indonesian, icelandic, italian, latin, mongolian, dutch, norsk, polish, por
tuguese, pinyin, romanian, russian, slovenian, uppersorbian, serbian, swedish,
turkish, ukenglish, ukrainian, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo))
(/usr/share/texmf/tex/latex/type1cm/type1cm.sty)
(/usr/share/texmf/tex/latex/psnfss/helvet.sty
(/usr/share/texmf/tex/latex/graphics/keyval.sty))
(/usr/share/texmf/tex/latex/psnfss/courier.sty)
(/usr/share/texmf/tex/latex/base/textcomp.sty
(/usr/share/texmf/tex/latex/base/ts1enc.def))
(/usr/share/texmf/tex/latex/geometry/geometry.sty
Package geometry Warning: Over-specification in h'-direction.
width’ (5058.9pt) is ignored.
Package geometry Warning: Over-specification in v'-direction.
height’ (5058.9pt) is ignored.
)
No file f5e3ddba2ab4bf5147d4e32e96deb043.aux.
(/usr/share/texmf/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf/tex/latex/psnfss/ot1pnc.fd)
(/usr/share/texmf/tex/latex/psnfss/ot1phv.fd)
! Undefined control sequence.
l.12 …ze{12.000000}{15.000000}{\sffamily {\color
{red} a red text}}
[1] (./f5e3ddba2ab4bf5147d4e32e96deb043.aux) )
(see the transcript file for additional information)
Output written on f5e3ddba2ab4bf5147d4e32e96deb043.dvi (1 page, 224 bytes).
Transcript written on f5e3ddba2ab4bf5147d4e32e96deb043.log.
Interestingly tex_demo.py works fine and renders the text properly onto the figure.
On Mon, Jan 11, 2010 at 4:36 AM, Damon McDougall <D.McDougall@…831…> wrote:
Hi Gökhan,
Do you have usetex=True set? If so, have you tried the LaTeX command sequence \color{red}{Red text goes here} ?
Regards,
– Damon
Damon McDougall
Mathematics Institute
University of Warwick
Coventry
CV4 7AL
d.mcdougall@…920…31…
On 11 Jan 2010, at 05:48, Gökhan Sever wrote:
Hello,
Is there a way to color words differently in a label or title, for example:
ylabel(“measurement 1 (in red color)” , “measurement 2 (in blue color)”) to match with the plotted line colors?
Thanks.
–
Gökhan
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon’s best-in-class app development supportA streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev _______________________________________________Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
–
Gökhan
First of all, to use "\color" with TeX, you need to use "color"
package, i.e., you need to modify your latex preamble to include that
package. This can be done by
import matplotlib.pyplot as plt
plt.rcParams["text.latex.preamble"] = r"\usepackage{color}"
I guess the error you encounter is because of this (I'm not sure as
the error message is slightly different in my machine).
However, this WON'T work in general!
The color information in the dvi (or png) file is ignored in most
cases (the only exception I know is the ps backend which does not read
in dvi of png output).
So, if you only want ps output, you can use usetex with "\color" command.
In matplotlib, a single Text object only have a single color
associated. So changing the color of the text within the string is be
hardly possible (except in the ps backend). So, I guess your best
option is to call "text" (or "annotate") multiple times with different
colors with fine-tuned text positions.
FYI, It is possible to have two (or more) text instances of different
colors packed together (somewhat similar to this example
http://matplotlib.sourceforge.net/plot_directive/users/plotting/examples/anchored_box04.hires.png),
Regards,
-JJ
On Mon, Jan 11, 2010 at 11:13 AM, Gökhan Sever <gokhansever@...287...> wrote:
This seems like the solution. However when I try:
I[1]: plt.plot(range(10))
I[2]: plt.ylabel(r"{\color{red} a red text}")It doesn't function and produce an ugly set of error messages:
I[3]: ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (573, 0))ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (573, 0))ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (573, 0))ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (573, 0))ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (566, 0))---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_qt4.pyc
in resizeEvent(self, event)
167 hinch = h/dpival
168 self.figure.set_size_inches( winch, hinch )
--> 169 self.draw()
170 self.update()
171 QtGui.QWidget.resizeEvent(self, event)/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_qt4agg.pyc
in draw(self)
128 if DEBUG: print "FigureCanvasQtAgg.draw", self
129 self.replot = True
--> 130 FigureCanvasAgg.draw(self)
131 self.update()
132/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_agg.pyc
in draw(self)
386
387 self.renderer = self.get_renderer()
--> 388 self.figure.draw(self.renderer)
389
390 def get_renderer(self):/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in
draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
---> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/figure.pyc in
draw(self, renderer)
800 dsu.sort(key=itemgetter(0))
801 for zorder, func, args in dsu:
--> 802 func(*args)
803
804 renderer.close_group('figure')/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in
draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
---> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axes.pyc in
draw(self, renderer, inframe)
1755
1756 for zorder, a in dsu:
-> 1757 a.draw(renderer)
1758
1759 renderer.close_group('axes')/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in
draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
---> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axis.pyc in
draw(self, renderer, *args, **kwargs)
819 self._update_label_position(ticklabelBoxes, ticklabelBoxes2)
820
--> 821 self.label.draw(renderer)
822
823 self._update_offset_text_position(ticklabelBoxes,
ticklabelBoxes2)/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in
draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
---> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/text.pyc in
draw(self, renderer)
547 renderer.open_group('text', self.get_gid())
548
--> 549 bbox, info = self._get_layout(renderer)
550 trans = self.get_transform()
551/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/text.pyc in
_get_layout(self, renderer)
303 w, h, d = get_text_width_height_descent(clean_line,
304
self._fontproperties,
--> 305 ismath=ismath)
306 if baseline is None:
307 baseline = h - d/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_agg.pyc
in get_text_width_height_descent(self, s, prop, ismath)
169 fontsize = prop.get_size_in_points()
170 w, h, d = texmanager.get_text_width_height_descent(s,
fontsize,
--> 171
renderer=self)
172 return w, h, d
173/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/texmanager.pyc in
get_text_width_height_descent(self, tex, fontsize, renderer)
599 else:
600 # use dviread. It sometimes returns a wrong descent.--> 601 dvifile = self.make_dvi(tex, fontsize)
602 dvi = dviread.Dvi(dvifile, 72*dpi_fraction)
603 page = iter(dvi).next()/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/texmanager.pyc in
make_dvi(self, tex, fontsize)
369 if exit_status or not exists:
370 raise RuntimeError(('LaTeX was not able to process
the following \
--> 371 string:\n%s\nHere is the full report generated by LaTeX: \n\n'%
repr(tex)) + report)
372 else: mpl.verbose.report(report, 'debug')
373 for fname in glob.glob(basefile+'*'):RuntimeError: LaTeX was not able to process the following string:
'{\\color{red} a red text}'
Here is the full report generated by LaTeX:This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
%&-line parsing enabled.
entering extended mode
(./f5e3ddba2ab4bf5147d4e32e96deb043.tex
LaTeX2e <2005/12/01>
Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang,
noh
yphenation, arabic, basque, bulgarian, coptic, welsh, czech, slovak, german,
ng
erman, danish, esperanto, spanish, catalan, galician, estonian, farsi,
finnish,
french, greek, monogreek, ancientgreek, croatian, hungarian, interlingua,
ibyc
us, indonesian, icelandic, italian, latin, mongolian, dutch, norsk, polish,
por
tuguese, pinyin, romanian, russian, slovenian, uppersorbian, serbian,
swedish,
turkish, ukenglish, ukrainian, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo))
(/usr/share/texmf/tex/latex/type1cm/type1cm.sty)
(/usr/share/texmf/tex/latex/psnfss/helvet.sty
(/usr/share/texmf/tex/latex/graphics/keyval.sty))
(/usr/share/texmf/tex/latex/psnfss/courier.sty)
(/usr/share/texmf/tex/latex/base/textcomp.sty
(/usr/share/texmf/tex/latex/base/ts1enc.def))
(/usr/share/texmf/tex/latex/geometry/geometry.styPackage geometry Warning: Over-specification in `h'-direction.
`width' (5058.9pt) is ignored.Package geometry Warning: Over-specification in `v'-direction.
`height' (5058.9pt) is ignored.)
No file f5e3ddba2ab4bf5147d4e32e96deb043.aux.
(/usr/share/texmf/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf/tex/latex/psnfss/ot1pnc.fd)
(/usr/share/texmf/tex/latex/psnfss/ot1phv.fd)
! Undefined control sequence.
l.12 ...ze{12.000000}{15.000000}{\sffamily {\color
{red} a red text}}
[1] (./f5e3ddba2ab4bf5147d4e32e96deb043.aux) )
(see the transcript file for additional information)
Output written on f5e3ddba2ab4bf5147d4e32e96deb043.dvi (1 page, 224 bytes).
Transcript written on f5e3ddba2ab4bf5147d4e32e96deb043.log.Interestingly tex_demo.py works fine and renders the text properly onto the
figure.On Mon, Jan 11, 2010 at 4:36 AM, Damon McDougall <D.McDougall@...831...> > wrote:
Hi Gökhan,
Do you have usetex=True set? If so, have you tried the LaTeX command
sequence \color{red}{Red text goes here} ?
Regards,
-- Damon--------------------------
Damon McDougall
Mathematics Institute
University of Warwick
Coventry
CV4 7AL
d.mcdougall@...831...
On 11 Jan 2010, at 05:48, Gökhan Sever wrote:Hello,
Is there a way to color words differently in a label or title, for
example:ylabel("measurement 1 (in red color)" , "measurement 2 (in blue color)")
to match with the plotted line colors?Thanks.
--
Gökhan------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and
easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options--
Gökhan------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
OK JJ,
After reading your explanation, I have tried my current Qt4Agg and PS backends. As you told coloring worked only with PS backend. See my sample test-snippets.
plt.rcParams[“text.latex.preamble”] = r"\usepackage{color}"
plt.plot(range(10)); plt.ylabel(“\color{red} {red}, \color{blue} {blue}”); plt.savefig(“hello.png”)
See the saved png and ps files at
http://ccnworks.googlecode.com/svn/trunk/hello.png
http://ccnworks.googlecode.com/svn/trunk/hello.ps
Another thing I noted in these images, Qt4Agg produced one looks much prettier to my eyes than the PS. What could be causing the jiggly rendering in the PS?
Any ideas?
On Mon, Jan 11, 2010 at 1:10 PM, Jae-Joon Lee <lee.j.joon@…287…> wrote:
First of all, to use “\color” with TeX, you need to use “color”
package, i.e., you need to modify your latex preamble to include that
package. This can be done by
import matplotlib.pyplot as plt
plt.rcParams[“text.latex.preamble”] = r"\usepackage{color}"
I guess the error you encounter is because of this (I’m not sure as
the error message is slightly different in my machine).
However, this WON’T work in general!
The color information in the dvi (or png) file is ignored in most
cases (the only exception I know is the ps backend which does not read
in dvi of png output).
So, if you only want ps output, you can use usetex with “\color” command.
In matplotlib, a single Text object only have a single color
associated. So changing the color of the text within the string is be
hardly possible (except in the ps backend). So, I guess your best
option is to call “text” (or “annotate”) multiple times with different
colors with fine-tuned text positions.
FYI, It is possible to have two (or more) text instances of different
colors packed together (somewhat similar to this example
http://matplotlib.sourceforge.net/plot_directive/users/plotting/examples/anchored_box04.hires.png),
Regards,
-JJ
On Mon, Jan 11, 2010 at 11:13 AM, Gökhan Sever <gokhansever@…287…> wrote:
This seems like the solution. However when I try:
I[1]: plt.plot(range(10))
I[2]: plt.ylabel(r"{\color{red} a red text}")
It doesn’t function and produce an ugly set of error messages:
I[3]: ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: (‘EOF in multi-line statement’, (573, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: (‘EOF in multi-line statement’, (573, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: (‘EOF in multi-line statement’, (573, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: (‘EOF in multi-line statement’, (573, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: (‘EOF in multi-line statement’, (566, 0))
RuntimeError Traceback (most recent call last)
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_qt4.pyc
in resizeEvent(self, event)
167 hinch = h/dpival
168 self.figure.set_size_inches( winch, hinch )
→ 169 self.draw()
170 self.update()
171 QtGui.QWidget.resizeEvent(self, event)
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_qt4agg.pyc
in draw(self)
128 if DEBUG: print "FigureCanvasQtAgg.draw", self
129 self.replot = True
→ 130 FigureCanvasAgg.draw(self)
131 self.update()
132
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_agg.pyc
in draw(self)
386
387 self.renderer = self.get_renderer()
→ 388 self.figure.draw(self.renderer)
389
390 def get_renderer(self):
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in
draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
—> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/figure.pyc in
draw(self, renderer)
800 dsu.sort(key=itemgetter(0))
801 for zorder, func, args in dsu:
→ 802 func(*args)
803
804 renderer.close_group('figure')
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in
draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
—> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axes.pyc in
draw(self, renderer, inframe)
1755
1756 for zorder, a in dsu:
→ 1757 a.draw(renderer)
1758
1759 renderer.close_group(‘axes’)
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in
draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
—> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/axis.pyc in
draw(self, renderer, *args, **kwargs)
819 self._update_label_position(ticklabelBoxes, ticklabelBoxes2)
820
→ 821 self.label.draw(renderer)
822
823 self._update_offset_text_position(ticklabelBoxes,
ticklabelBoxes2)
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/artist.pyc in
draw_wrapper(artist, renderer, *kl)
53 def draw_wrapper(artist, renderer, *kl):
54 before(artist, renderer)
—> 55 draw(artist, renderer, *kl)
56 after(artist, renderer)
57
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/text.pyc in
draw(self, renderer)
547 renderer.open_group('text', self.get_gid())
548
→ 549 bbox, info = self._get_layout(renderer)
550 trans = self.get_transform()
551
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/text.pyc in
_get_layout(self, renderer)
303 w, h, d = get_text_width_height_descent(clean_line,
304
self._fontproperties,
→ 305 ismath=ismath)
306 if baseline is None:
307 baseline = h - d
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/backends/backend_agg.pyc
in get_text_width_height_descent(self, s, prop, ismath)
169 fontsize = prop.get_size_in_points()
170 w, h, d = texmanager.get_text_width_height_descent(s,
fontsize,
→ 171
renderer=self)
172 return w, h, d
173
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/texmanager.pyc in
get_text_width_height_descent(self, tex, fontsize, renderer)
599 else:
600 # use dviread. It sometimes returns a wrong descent.
→ 601 dvifile = self.make_dvi(tex, fontsize)
602 dvi = dviread.Dvi(dvifile, 72*dpi_fraction)
603 page = iter(dvi).next()
/home/gsever/Desktop/python-repo/matplotlib/lib/matplotlib/texmanager.pyc in
make_dvi(self, tex, fontsize)
369 if exit_status or not exists:
370 raise RuntimeError(('LaTeX was not able to process
the following \
→ 371 string:\n%s\nHere is the full report generated by LaTeX: \n\n’%
repr(tex)) + report)
372 else: mpl.verbose.report(report, 'debug')
373 for fname in glob.glob(basefile+'*'):
RuntimeError: LaTeX was not able to process the following string:
‘{\color{red} a red text}’
Here is the full report generated by LaTeX:
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
%&-line parsing enabled.
entering extended mode
(./f5e3ddba2ab4bf5147d4e32e96deb043.tex
LaTeX2e <2005/12/01>
Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang,
noh
yphenation, arabic, basque, bulgarian, coptic, welsh, czech, slovak, german,
ng
erman, danish, esperanto, spanish, catalan, galician, estonian, farsi,
finnish,
french, greek, monogreek, ancientgreek, croatian, hungarian, interlingua,
ibyc
us, indonesian, icelandic, italian, latin, mongolian, dutch, norsk, polish,
por
tuguese, pinyin, romanian, russian, slovenian, uppersorbian, serbian,
swedish,
turkish, ukenglish, ukrainian, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo))
(/usr/share/texmf/tex/latex/type1cm/type1cm.sty)
(/usr/share/texmf/tex/latex/psnfss/helvet.sty
(/usr/share/texmf/tex/latex/graphics/keyval.sty))
(/usr/share/texmf/tex/latex/psnfss/courier.sty)
(/usr/share/texmf/tex/latex/base/textcomp.sty
(/usr/share/texmf/tex/latex/base/ts1enc.def))
(/usr/share/texmf/tex/latex/geometry/geometry.sty
Package geometry Warning: Over-specification in `h’-direction.
`width' (5058.9pt) is ignored.
Package geometry Warning: Over-specification in `v’-direction.
`height' (5058.9pt) is ignored.
)
No file f5e3ddba2ab4bf5147d4e32e96deb043.aux.
(/usr/share/texmf/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf/tex/latex/psnfss/ot1pnc.fd)
(/usr/share/texmf/tex/latex/psnfss/ot1phv.fd)
! Undefined control sequence.
l.12 …ze{12.000000}{15.000000}{\sffamily {\color
{red} a red text}}
[1] (./f5e3ddba2ab4bf5147d4e32e96deb043.aux) )
(see the transcript file for additional information)
Output written on f5e3ddba2ab4bf5147d4e32e96deb043.dvi (1 page, 224 bytes).
Transcript written on f5e3ddba2ab4bf5147d4e32e96deb043.log.
Interestingly tex_demo.py works fine and renders the text properly onto the
figure.
On Mon, Jan 11, 2010 at 4:36 AM, Damon McDougall <D.McDougall@…831…> > > > wrote:
Hi Gökhan,
Do you have usetex=True set? If so, have you tried the LaTeX command
sequence \color{red}{Red text goes here} ?
Regards,
– Damon
Damon McDougall
Mathematics Institute
University of Warwick
Coventry
CV4 7AL
d.mcdougall@…831…
On 11 Jan 2010, at 05:48, Gökhan Sever wrote:
Hello,
Is there a way to color words differently in a label or title, for
example:
ylabel(“measurement 1 (in red color)” , “measurement 2 (in blue color)”)
to match with the plotted line colors?
Thanks.
–
Gökhan
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon’s best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and
easy
Join now and get one step closer to millions of Verizon customers
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
–
Gökhan
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon’s best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
–
Gökhan
The rendering quality of the fonts depends on a lot of things.
And I think your ps file itself is okay, but the rendering application
you use is doing a poor job. For example, convert the ps file to pdf
and open in the acroread (or whatever you use).
-JJ
On Mon, Jan 11, 2010 at 3:20 PM, Gökhan Sever <gokhansever@...287...> wrote:
Another thing I noted in these images, Qt4Agg produced one looks much
prettier to my eyes than the PS. What could be causing the jiggly rendering
in the PS?
Another thing I noted in these images, Qt4Agg produced one looks much
prettier to my eyes than the PS. What could be causing the jiggly rendering
in the PS?
The rendering quality of the fonts depends on a lot of things.
And I think your ps file itself is okay, but the rendering application
you use is doing a poor job. For example, convert the ps file to pdf
and open in the acroread (or whatever you use).
Yes, it did the job. Thanks for the tip. The fonts look also nicer in PDF. The last interesting thing in the files, the line is rendered as blue on PNG, however in the PS it is red.
On Tue, Jan 12, 2010 at 2:46 PM, Jae-Joon Lee <lee.j.joon@…287…> wrote:
On Mon, Jan 11, 2010 at 3:20 PM, Gökhan Sever <gokhansever@…287…> wrote:
-JJ
–
Gökhan
Allright, I have another comparison.
My simple hello.ps file produced by the svn MPL vs test_idl.ps (which has a lot plots --only for test purposes.) file produced by IDL. When I converted the ps file to pdf (using ps2pdf tool) it gets shinier.
http://ccnworks.googlecode.com/svn/trunk/hello.ps
http://ccnworks.googlecode.com/svn/trunk/hello.pdf
http://ccnworks.googlecode.com/svn/trunk/test_idl.ps
Some technical details regarding to the files:
hello.ps
Creator: GPL Ghostscript 870 (pswrite)
Format: PS-Adobe-3.0
test_idl.ps
Creator: IDL Version 7.1 (linux x86 m32)
Format: PS-Adobe-3.0
See the formats are same. IDL’s ps creator does a much better job than the Ghostscript. (Both in terms of fonts and lines, actual frame looks nice in both ps and pdf files.) I use Evince Document Viewer v2.28.2 to view these files.
What could be causing this discrepancy? Is there any way to use an alternative PS creator with MPL? or an option to increase e.g. bits per pixel option somewhere in the configuration?
Thanks.
On Tue, Jan 12, 2010 at 2:52 PM, Gökhan Sever <gokhansever@…287…> wrote:
On Tue, Jan 12, 2010 at 2:46 PM, Jae-Joon Lee <lee.j.joon@…287…> wrote:
On Mon, Jan 11, 2010 at 3:20 PM, Gökhan Sever <gokhansever@…287…> wrote:
Another thing I noted in these images, Qt4Agg produced one looks much
prettier to my eyes than the PS. What could be causing the jiggly rendering
in the PS?
The rendering quality of the fonts depends on a lot of things.
And I think your ps file itself is okay, but the rendering application
you use is doing a poor job. For example, convert the ps file to pdf
and open in the acroread (or whatever you use).
Yes, it did the job. Thanks for the tip. The fonts look also nicer in PDF. The last interesting thing in the files, the line is rendered as blue on PNG, however in the PS it is red.
-JJ
–
Gökhan
–
Gökhan
There can be a lot of things. However, you cannot just say one is
better than the other based on how it looks on your monitor screen.
As far as I can tell, postscript is best for printing, but not very
optimal for your monitor screen.
While matplotlib with the xpdf distiller could be better than
ghostsrcipt one in this regard, but, again, postscipt on your monitor
screen does not make much sense, at least to me.
-JJ
On Tue, Jan 12, 2010 at 9:56 PM, Gökhan Sever <gokhansever@...287...> wrote:
What could be causing this discrepancy? Is there any way to use an
alternative PS creator with MPL? or an option to increase e.g. bits per
pixel option somewhere in the configuration?
What could be causing this discrepancy? Is there any way to use an
alternative PS creator with MPL? or an option to increase e.g. bits per
pixel option somewhere in the configuration?
There can be a lot of things. However, you cannot just say one is
better than the other based on how it looks on your monitor screen.
As far as I can tell, postscript is best for printing, but not very
optimal for your monitor screen.
I printed the PNG and PS file. The result looks same on paper as well. I was comparing the two ps file one from IDL one from MPL. IDL looks neat both on the screen and printed.
While matplotlib with the xpdf distiller could be better than
ghostsrcipt one in this regard, but, again, postscipt on your monitor
screen does not make much sense, at least to me.
-JJ
OK, here is one more comparison.
I use xpdf distiller, and set the pdf comparison to 0 in the rc file.
http://ccnworks.googlecode.com/svn/trunk/test.png
http://ccnworks.googlecode.com/svn/trunk/test.ps
http://ccnworks.googlecode.com/svn/trunk/test.eps
http://ccnworks.googlecode.com/svn/trunk/test.pdf
PS and EPS outputs are almost alike to my eye. Setting ps.distiller.res to 6000 DPI doesn’t make a difference either. PDF backend produces the highest quality output. However the problem with that I can’t include pdf images on a regular OpenOffice document
With xpdf the line is plotted blue correctly as it is seen on my screen. Before it was drawing a red-line.
On Wed, Jan 13, 2010 at 10:08 AM, Jae-Joon Lee <lee.j.joon@…287…> wrote:
On Tue, Jan 12, 2010 at 9:56 PM, Gökhan Sever <gokhansever@…287…> wrote:
–
Gökhan
It seems like ps.distiller.res parameter doesn’t have an effect on the output ps file. I set this to 60 and 6000 and 60000 it all produces same sized same looking figures. Any ideas?
On Wed, Jan 13, 2010 at 10:32 AM, Gökhan Sever <gokhansever@…287…> wrote:
On Wed, Jan 13, 2010 at 10:08 AM, Jae-Joon Lee <lee.j.joon@…287…> wrote:
On Tue, Jan 12, 2010 at 9:56 PM, Gökhan Sever <gokhansever@…287…> wrote:
What could be causing this discrepancy? Is there any way to use an
alternative PS creator with MPL? or an option to increase e.g. bits per
pixel option somewhere in the configuration?
There can be a lot of things. However, you cannot just say one is
better than the other based on how it looks on your monitor screen.
As far as I can tell, postscript is best for printing, but not very
optimal for your monitor screen.
I printed the PNG and PS file. The result looks same on paper as well. I was comparing the two ps file one from IDL one from MPL. IDL looks neat both on the screen and printed.
While matplotlib with the xpdf distiller could be better than
ghostsrcipt one in this regard, but, again, postscipt on your monitor
screen does not make much sense, at least to me.
-JJ
OK, here is one more comparison.
I use xpdf distiller, and set the pdf comparison to 0 in the rc file.
http://ccnworks.googlecode.com/svn/trunk/test.png
http://ccnworks.googlecode.com/svn/trunk/test.ps
http://ccnworks.googlecode.com/svn/trunk/test.epshttp://ccnworks.googlecode.com/svn/trunk/test.pdf
PS and EPS outputs are almost alike to my eye. Setting ps.distiller.res to 6000 DPI doesn’t make a difference either. PDF backend produces the highest quality output. However the problem with that I can’t include pdf images on a regular OpenOffice document
With xpdf the line is plotted blue correctly as it is seen on my screen. Before it was drawing a red-line.
–
Gökhan
–
Gökhan
Are you saying that the printout of the mpl-created postscript file
still shows the jiggly rendering as displayed in your monitor? I
highly doubt that (hmm, but it may depends on how you print the
files).
ps or pdf, as far as same font is used, I don't see any reason that
pdf quality is better than ps (and I never felt that way in my
experience). Again, monitor display is a different story.
Again, if you want your figures look goon on your monitor, postscript
is not the way to go in my opinion. And I don't think this is an issue
of the matplotlib side, so I'm afraid that there is anything I can
help in this regard.
Regards,
-JJ
On Wed, Jan 13, 2010 at 11:32 AM, Gökhan Sever <gokhansever@...287...> wrote:
I printed the PNG and PS file. The result looks same on paper as well. I was
comparing the two ps file one from IDL one from MPL. IDL looks neat both on
the screen and printed.
I printed the PNG and PS file. The result looks same on paper as well. I was
comparing the two ps file one from IDL one from MPL. IDL looks neat both on
the screen and printed.
Are you saying that the printout of the mpl-created postscript file
still shows the jiggly rendering as displayed in your monitor? I
highly doubt that (hmm, but it may depends on how you print the
files).
This is true, the printout looks ugly like I am seeing on my monitor. I am on Fedora 12, and use the print menu of my evince tool to print out the file. Is there a special method to print eps files?
ps or pdf, as far as same font is used, I don’t see any reason that
pdf quality is better than ps (and I never felt that way in my
experience). Again, monitor display is a different story.
See the last comparison screenshot: http://img40.imageshack.us/img40/7461/pdfepspng.png
And these are settings that I enabled while creating this plots. (Plus for the png I used 600 dpi)
ps.papersize : auto # auto, letter, legal, ledger, A0-A10, B0-B10
ps.usedistiller : xpdf # can be: None, ghostscript or xpdf
ps.distiller.res : 6000 # dpi
ps.fonttype : 42 # Output Type 3 (Type3) or Type 42 (TrueType)
pdf.compression : 0 # integer from 0 to 9
pdf.fonttype : 42 # Output Type 3 (Type3) or Type 42 (TrueType)
PNG with high resolution produces the nicest looking plot. PDF follows it. However EPS file still looks ugly. What are your font suggestions? An any ideas why ps.distiller.res has no effect on the produced plot?
Could somebody reproduce the similar results?
Thanks.
On Wed, Jan 13, 2010 at 11:22 AM, Jae-Joon Lee <lee.j.joon@…287…> wrote:
On Wed, Jan 13, 2010 at 11:32 AM, Gökhan Sever <gokhansever@…287…> wrote:
Again, if you want your figures look goon on your monitor, postscript
is not the way to go in my opinion. And I don’t think this is an issue
of the matplotlib side, so I’m afraid that there is anything I can
help in this regard.
Regards,
-JJ
–
Gökhan