matplotlib.text.Text.cached causing problems

Hi there,

matplotlib.text.Text._get_layout(self, renderer) caches
its return value in the dictionary matplotlib.text.Text.cached.
Since it is never emptied, it causes problems when one
creates many figures.

Below, t0.png is ok but t1.png has the vertical tick label 0 in the
wrong place.

import matplotlib
matplotlib.use('Agg')
from matplotlib.matlab import *

y = [[100, 250], [10, 25]]

for i in range(2):
    figure(1)
    bar([0,1], y[i])
    savefig('t%d.png' % i)
    # Uncomment to fix
    #matplotlib.text.Text.cached = {}
    close('all')

···

--
Patrik

Here's a proposed patch for the caching problem in text.py.
(I'm sending it before someone actually adds
matplotlib.text.Text.cached = {}
to, e.g., matlab.close(). Oh, the horror :slight_smile:

text.py.diff (1.33 KB)

···

--
Patrik