pylab

Bar plots and legends in pylab/matplotlib

13 June, 2009 - 09:41

I like working with Matplotlib aka Pylab for my plotting needs in Python, but today I stumbled on a weird issue when creating a mixed bar + line plot with legend. Take the following snippet:

pylab.bar(x, yr, color='#88aa33', align='center', label='histogram')
pylab.plot(x, yc, 'bo-', label='cumulative')
pylab.legend()

This generates something like (note the entry overload in the legend):

Legend entry overload.

[Update: this issue seems to be solved. The issue described here occurred with Matplotlib version 0.91.2. With Matplotlib 0.99.0 I don't have this problem anymore.]

Read more...

Date tick control in pylab/matplotlib

18 May, 2009 - 14:05

Today I struggled a bit with pylab's plot_date function and overlapping date tick labels:

overlapping plot_date xticks

Read more...

a clash between locale settings, C extension Python modules and pylab (aka matplotlib)

6 March, 2006 - 16:58

This weekend I encountered a weird problem during programming C extension modules for Python. For some obscure reason floats from my C extension modules were formatted with a comma as separater (e.g. 123,456) instead of with the more familiar point (e.g. 123.456). Obviously some locale related problem. Most of my desktop and applications are set up for Dutch (my native language), but when I'm programming/working I use English and scientific conventions (e.g. a point as decimal separator). After isolating the problem I found out it was related to importing the pylab (aka Matplotlib) module (which I started using for plotting graphs and figures from Python). The following situation illustrates the problem.

Read more...