Labels clipped

I wrote:

    >> How can I decrease the size of the actual graph so that the
    >> labels are displayed?
    >>
    > The answer seems to be to use the following after drawing
    > the graph: ax = gca() ax.set_position([0.2,0.2,0.6,0.6])

    > This was taken from the mailing list discussion on
    > GnuPlot's 'set size ratio' command -
    > (http://sourceforge.net/mailarchive/forum.php?thread_id=5562487&forum_id=33405)

    > Is this the correct approach?

Yep, that's it -- this is also discussed here
http://matplotlib.sf.net/faq.html#TEXTOVERLAP , which also gives
an alternative suggestion.

    > PS One thing that I am having trouble getting my head
    > around fully is how best to handle the coding, i.e. I'd
    > prefer to use the class library approach as I like it's
    > clean, well structured nature, but a number of techniques,
    > such as the above, are written/illustrated using the
    > Pylab/Matlab commands which I find difficult to translate
    > into the class library code. What is the best approach to
    > getting up the learning curve? Are there any problems with
    > mixing the two approaches in the one code base?

It's a common complaint, so don't feel along. Have you seen
examples/pythonic_matplotlib.py -- there is some header documentation
there that offers some pointers. That is an example using the pylab
interface in a more OO way. For pure OO w/o the pylab interface at
all, there is a new example in CVS which I'll put here

    #!/usr/bin/env python
    """
    A pure OO (look Ma, no pylab!) example using the agg backend
    """
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    from matplotlib.figure import Figure

    fig = Figure()
    canvas = FigureCanvas(fig)
    ax = fig.add_subplot(111)
    ax.plot([1,2,3])
    ax.set_title('hi mom')
    ax.grid(True)
    ax.set_xlabel('time')
    ax.set_ylabel('volts')
    canvas.print_figure('test')

My advice, don't be afraid to open up matplotlib/pylab.py to see how
the pylab interface forwards its calls to the OO layer. I appreciate
that "read the source" is not very comforting, but that, the examples
I pointed you too above, the all-too-short Chapter 7 of the user's
guide, the examples/embedding* demos, and the mailing lists, which are
regularly read by many developers, are what we've got right now.

I always encourage new users starting on the path to matplotlib OO API
enlightenment to make notes and write a tutorial as you go. It would
be a useful addition to the documentation.

JDH

John Hunter wrote:

    > Is this the correct approach?

Yep, that's it -- this is also discussed here
http://matplotlib.sf.net/faq.html#TEXTOVERLAP , which also gives
an alternative suggestion.

(Ahhh - a small light bulb is lit!)
Ok, I'd seen that but wasn't able to get it to work but now I understand why - when I tried it I'd not made the connection between axes and sub-plots.

For pure OO w/o the pylab interface at
all, there is a new example in CVS which I'll put here

Thanks, I'll check it out.

[Snip some good advice]

I always encourage new users starting on the path to matplotlib OO API
enlightenment to make notes and write a tutorial as you go. It would
be a useful addition to the documentation.

No promises - so much to do, so little time :frowning:
I've got to code up the generation of more than 80 different graphs, resulting in over 32k individual instances, which is why I'm looking at matplotlib in preference to gnuplot, hopefully there's less trial and error involved in getting each graph 'just so'.

A Wiki might make the tutorial/documentation more achievable/accessible, is there one available?

Robert