473,503 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

matplotlib, usetex

Hi, I'm having some trouble plotting with the following matplotlibrc:

text.usetex : True

I tried clearing the cache files under ~/.matplotlib, but this did not
help the problem. I'd post on the matplotlib mailing list, but I have a
hard enough time browsing sourceforge's achives (frequent internal
server errors). Here is some output:
---- example.py ----
import pylab
pylab.plot(range(10))
pylab.show()
--------------------

# python example.py --verbose-helpful
matplotlib data path /usr/share/matplotlib/mpl-data
$HOME=/home/me
loaded rc file /home/me/matplotlibrc
matplotlib version 0.87.7
verbose.level helpful
interactive is False
platform is linux2
numerix Numeric 24.2
font search path ['/usr/share/matplotlib/mpl-data']
CONFIGDIR=/home/me/.matplotlib
loaded ttfcache file /home/me/.matplotlib/ttffont.cache
backend GTK version 2.10.4
Traceback (most recent call last):
File "example.py", line 2, in <module>
pylab.plot(range(10))
File "/usr/lib/python2.5/site-packages/matplotlib/pylab.py", line
2027, in plot
ret = gca().plot(*args, **kwargs)
File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line
2131, in plot
self.autoscale_view(scalex=scalex, scaley=scaley)
File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line 985,
in autoscale_view
self.set_xlim(XL)
File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line
1227, in set_xlim
self.viewLim.intervalx().set_bounds(xmin, xmax)
TypeError: only length-1 arrays can be converted to Python scalars.
The problem does not exist when text.usetex is False. Ideas?

May 25 '07 #1
4 3322
Bill Jackson <ja*****@hotmail.comwrites:
>
The problem does not exist when text.usetex is False. Ideas?
I have no idea whether this will resolve your problem, but you could try
updating to 0.90 (BTW what happens if you do axis([0,128,0,128])).

cheers,

'as
May 25 '07 #2
Alexander Schmolck wrote the following on 05/25/2007 02:33 PM:
(BTW what happens if you do axis([0,128,0,128])).
In [1]: import pylab

In [2]: pylab.axis([0,128,0,128])

In [3]: pylab.show()
---------------------------------------------------------------------------
<type 'exceptions.NotImplementedError' Traceback (most recent call last)

/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py in
expose_event(self, widget, event)
282 x, y, w, h = self.allocation
283 self._pixmap_prepare (w, h)
--284 self._render_figure(self._pixmap, w, h)
285 self._need_redraw = False
286

/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py in
_render_figure(self, pixmap, width, height)
270 """
271 self._renderer.set_width_height (width, height)
--272 self.figure.draw (self._renderer)
273
274

/usr/lib/python2.5/site-packages/matplotlib/figure.py in draw(self,
renderer)
542
543 # render the axes
--544 for a in self.axes: a.draw(renderer)
545
546 # render the figure text

/usr/lib/python2.5/site-packages/matplotlib/axes.py in draw(self,
renderer, inframe)
1061
1062 for zorder, i, a in dsu:
-1063 a.draw(renderer)
1064
1065 self.transData.thaw() # release the lazy objects

/usr/lib/python2.5/site-packages/matplotlib/axis.py in draw(self,
renderer, *args, **kwargs)
559 tick.set_label1(label)
560 tick.set_label2(label)
--561 tick.draw(renderer)
562 if tick.label1On and tick.label1.get_visible():
563 extent = tick.label1.get_window_extent(renderer)

/usr/lib/python2.5/site-packages/matplotlib/axis.py in draw(self, renderer)
159 if self.tick2On: self.tick2line.draw(renderer)
160
--161 if self.label1On: self.label1.draw(renderer)
162 if self.label2On: self.label2.draw(renderer)
163

/usr/lib/python2.5/site-packages/matplotlib/text.py in draw(self, renderer)
836 def draw(self, renderer):
837 self.update_coords(renderer)
--838 Text.draw(self, renderer)
839 if self.get_dashlength() 0.0:
840 self.dashline.draw(renderer)

/usr/lib/python2.5/site-packages/matplotlib/text.py in draw(self, renderer)
348
349 renderer.draw_tex(gc, x, y, line,
--350 self._fontproperties, angle)
351 return
352

/usr/lib/python2.5/site-packages/matplotlib/backend_bases.py in
draw_tex(self, gc, x, y, s, prop, angle, ismath)
379
380 def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!'):
--381 raise NotImplementedError
382
383 def draw_text(self, gc, x, y, s, prop, angle, ismath=False):

<type 'exceptions.NotImplementedError'>:

In [4]:

May 25 '07 #3
Alexander Schmolck wrote the following on 05/25/2007 02:33 PM:
I have no idea whether this will resolve your problem, but you could try
updating to 0.90 (BTW what happens if you do axis([0,128,0,128])).
The problem appears to be with a matplotlibrc file. If I delete the
matplotlibrc file, then I am able to plot perfectly. Thus, it appears
that I am unable to specify usetex from my configuration file. Why is
this happening?

---- ~/.matplotlib/matplotlibrc ----
text.usetex : True

---- test.py ----
import matplotlib
import pylab
matplotlib.rc('text', usetex=True)
pylab.plot(range(10))
pylab.show()
Running 'python test.py' with the above matplotlibrc causes the errors
in my original post. Deleting matplotlibrc resolves the problem.

May 26 '07 #4
Bill Jackson <ja*****@hotmail.comwrites:
Alexander Schmolck wrote the following on 05/25/2007 02:33 PM:
>I have no idea whether this will resolve your problem, but you could try
updating to 0.90 (BTW what happens if you do axis([0,128,0,128])).

The problem appears to be with a matplotlibrc file. If I delete the
matplotlibrc file, then I am able to plot perfectly. Thus, it appears that I
am unable to specify usetex from my configuration file. Why is this
happening?

---- ~/.matplotlib/matplotlibrc ----
text.usetex : True

---- test.py ----
import matplotlib
import pylab
matplotlib.rc('text', usetex=True)
I think it might be a good habit to develop to call ``rc`` before ``import
pylab`` -- some things won't take effect otherwise (this doesn't affect all
parameters and will likely be eventually fixed in general, but notably it does
currently affect some latex-related stuff, such as font choice).
pylab.plot(range(10))
pylab.show()
Running 'python test.py' with the above matplotlibrc causes the errors in my
original post. Deleting matplotlibrc resolves the problem.
I can't see any problem with you matplotlibrc; what happens if you swap around
the lines as I suggested above? Maybe it just appears to work, because the
usetex really does have no affect above, and you really are not using latex?

I have been using matplotlib with latex for fonts handling for some time now
(and I've even submitted a patch to ameliorate the rc problem mentioned
above), but the latex stuff has changed somewhat over time, and still has some
rough edges -- so for not immediately obvious problems with the latex handling
of an older version of matplotlib you're much more likely to find someone who
has the relevant details mentally available on the matplotlib-disc list are
much better than here; so I'd recommend you give it a try again (yeah sf is a
pain).

cheers,

'as

May 27 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1751
by: John Hunter | last post by:
matplotlib is a 2D plotting package for python with a matlab compatible syntax and output tested under linux and windows platforms. matplotlib-0.30 is available for download at...
3
2592
by: John Hunter | last post by:
matplotlib is a 2D plotting library for python. You can use matplotlib interactively from a python shell or IDE, or embed it in GUI applications (WX, GTK, and Tkinter). matplotlib supports many...
2
11635
by: Grant Edwards | last post by:
I downloaded examples/contour_demo.py, and it doesn't run. I've searched both the user guide and the Wiki for "contour" and got zero hits. ...
0
2572
by: spross | last post by:
hi all i have to use matplotlib on mac os x. on the official site of matplotlib, i found a link to precompiled python packages for mac os x: http://pythonmac.org/packages/py24-fat/index.html ...
0
3379
by: Soren | last post by:
Hi, I've been trying to embed matplotlib in wxpython. I want to be able to put a figure (axes) in a wx.Panel and place it somewhere in my GUI. The GUI should have other panels with buttons etc....
3
4699
by: vajratkarviraj | last post by:
i hav python2.5, matplotlib0.90.1, and py2exe for python 2.5 all on windows xp... i hav a python program(letsc.py) which uses the matplotlib package... and i want 2 make an exe of it for distribution...
2
3516
by: John | last post by:
I'm trying to install matplotlib and currently getting the below error. I searched the group and google and couldn't find anything similar... Any ideas? Thanks in advance! src/ft2font.cpp:...
4
9648
by: John Henry | last post by:
Has anybody been able to create an exe of their python applications involving matplotlib using pyinstall (ver 1.3)? I am getting a: RuntimeError: Could not find the matplotlib data files when...
0
4312
by: PamMish1982 | last post by:
Hi all, I have recently started using Python and I am trying to make a GUI out of Tkinter. I am using matplotlib for the graphic purposes. I have to make a exe file from this code. I use py2exe...
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.