Problems with xlabel

Hi all, I have some problems with xlabel. Sometimes the text

    > is rotated (see ex3.png), but for what reason ?

    > figure(3) plot(real(data_eig),imag(data_eig),'b.')
    > xlabel(r'Real part $\nu_r$') ylabel(r'Imaginary $\nu_i$')
    > savefig('ex3.png')

Hi Nils,

After thinking about this and reading through the matplotlib src code,
I have been able to infer that you

* are working with a *Agg backend

* have set the rc param usetex=True in your rc file or called
   rc('text', usetex=True) before the indicated commands

* you have previously called code (perhaps in figure(1) or figure(2)
   not shown) with the x and y axes labels reversed.

The reason for the bug is that backend agg caches the dvipng
information, and the key to this dictionary cache is not using the
angle (it should). The following code reproduces the bug in *Agg

    rc('text', usetex=True)
    plot(rand(10), rand(10), 'b.')
    xlabel(r'Real part $\nu_r$')
    ylabel(r'Imaginary $\nu_i$')
    ylabel(r'Real part $\nu_r$')
    xlabel(r'Imaginary $\nu_i$')
The fix: in matplotlib/backends/ on or around line 268,

        key = s, size, dpi, rgb
        im = self.texd.get(key)


        key = s, size, dpi, rgb, angle
        im = self.texd.get(key)

And next time, provide enough information that someone with less than
superhuman inferential powers can reproduce the bug. A complete
example which reproduces it with any non-standard rc settings and the
output of your script run with --verbose-helpful would be much