Create a figure that is reference counted

If you create the figure without using plt.figure, then it should be reference counted as you expect. For example (This is using the non-interactive Agg backend, as well.) from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure # The pylab figure manager will be bypassed in this instance. # This means that `fig` will … Read more

Matplotlib: Writing right-to-left text (Hebrew, Arabic, etc.)

For Arabic you need both bidi.algorithm.get_display and arabic_reshaper modules: from bidi.algorithm import get_display import matplotlib.pyplot as plt import arabic_reshaper reshaped_text = arabic_reshaper.reshape(u’لغةٌ عربيّة’) artext = get_display(reshaped_text) plt.text(0.25, 0.45, artext , name=”Times New Roman”,fontsize=50) plt.show()

Get legend as a separate picture in Matplotlib

This could work: import pylab fig = pylab.figure() figlegend = pylab.figure(figsize=(3,2)) ax = fig.add_subplot(111) lines = ax.plot(range(10), pylab.randn(10), range(10), pylab.randn(10)) figlegend.legend(lines, (‘one’, ‘two’), ‘center’) fig.show() figlegend.show() figlegend.savefig(‘legend.png’)

matplotlib has no attribute ‘pyplot’

pyplot is a sub-module of matplotlib which doesn’t get imported with a simple import matplotlib. >>> import matplotlib >>> print matplotlib.pyplot Traceback (most recent call last): File “<stdin>”, line 1, in <module> AttributeError: ‘module’ object has no attribute ‘pyplot’ >>> import matplotlib.pyplot >>> It seems customary to do: import matplotlib.pyplot as plt at which time … Read more

matplotlib taking time when being imported

As tom suggested in the comment above, deleting the files: fontList.cache fontList.py3k.cache tex.cache solve the problem. In my case the files were under: `~/.matplotlib` EDITED A couple of days ago the message appeared again, I deleted the files in the locations mention above without any success. I found that as suggested here by T Mudau … Read more