Hello everyone. I have a problem about the PS backend and the Draw Event.

I read the "Automatically make room for tick labels" section 
<http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels>
 
in the matplotlib Howto page. It is very useful to my project, and I 
would like to adopt it. I wrote a test program as follows:

> #!/usr/bin/env python
>
> import matplotlib
> matplotlib.use("PS")
>
> import pylab
>
> def on_draw(event):
>     fig = pylab.gcf()
>     cur_bottom = fig.subplotpars.bottom
>
>     if cur_bottom != 0.2:
>         fig.subplots_adjust(bottom=0.2)
>         fig.canvas.draw()
>
>     print("moved bottom")
>
> pylab.xlabel("x axis\nlabel\nis\nlong")
> pylab.gcf().canvas.mpl_connect('draw_event', on_draw)
> #pylab.subplots_adjust(bottom=0.2)
>
> pylab.savefig("test.eps")
which just lifts the bottom to 0.2. If I execute this program, "moved 
bottom" is displayed just once, but the figure is actually not moved. If 
I simple uncomment the line after mpl_connect, figure is lifted. 
However, if I change the backend from "PS" to "Agg" and generate 
"test.png" instead, "moved bottom" is displayed twice, and figure is moved.

So I think when using Agg to generate png image, the canvas draw() 
invokes the Draw Event again and shows the second "moved bottom". This 
makes sense. My question is, when using PS backend,
why does not the subplots_adjust work in on_draw()? And why does not the 
canvas draw() invokes the Draw Event? Is this is an known issue?

I cannot switch my backend to Agg, because Agg does not produce hatch, 
which is essential to my images.

Thanks in advance for you help!

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to