Does ppi do anything with the Agg back end?

Hi all, I sent pretty much this question a couple days ago,

    > but it was tacked on to another thread, so it may have
    > gotten lost in the shuffle. So here it is again:

Sorry Chris, I got half way through answering this a few days ago but
had to take off midstream, and though I thought I had saved the post,
it was lost. Trying again.

    > This is how I thought MPL works, but it turns out I'm
    > wrong, as the example below indicates. What have I got
    > wrong?

    > 1) The size of a figure is defined in length units
    > (inches), and can be set by:

    > Figure.set_figsize_inches( (w,h) )

Yep.

    > 1b) The layout of the figure is defined in "figure units"
    > so it can be scaled by changing the figure size.

Not sure what this means, but you can change the figure size and the
layout (eg axes positions) will update.

    > 2) Size of text, width of lines, etc is defined in terms of
    > length units (points?).

Yes, points.

    > 3) When displaying to the screen, or creating an image
    > (PNG) the pixel size of text and line widths, etc is
    > determined by the dpi setting, which is set by:

    > Figure.set_dpi( val )

Yep. But you have to be careful here, because savefig has it's own
default dpi, so when creating hardcopy you will need to explicitly set dpi.q

    > The trick here is that when printing, it's natural to think
    > in terms of inches, but when creating an image (for a web
    > page, for instance), it is natural to think in terms of
    > pixel size. However, AFAIK, MPL does not have a way to set
    > the pixel size directly.

It does now. In 0.84 I added a canvas.resize(w,h) in pixels. So far
this has only been implemented in GTK*. If anyone wants to help with
the other backends, that would be great. See the thread on the dev
list "GUI maintainers: canvas.resize and ResizeEvent"

With the changes in that post, you can dynamically resize the canvas
or figure, eg from the interactive shell, and the GUI figure window
will update, as it should.

    > However, changing the dpi of the Figure doesn't seem to
    > have any effect. What's up John? shouldn't Figure.set_dpi
    > effect the dpi of the resulting PNG? I'm using MPL 0.84 on
    > Linux.

See the comment on savefig above.

Cheers,
JDH

John Hunter wrote:

Sorry Chris, I got half way through answering this a few days ago but
had to take off midstream, and though I thought I had saved the post,
it was lost. Trying again.

thanks, you're usually so responsive, I was surprised!

    > Figure.set_dpi( val )

Yep. But you have to be careful here, because savefig has it's own
default dpi, so when creating hardcopy you will need to explicitly set dpi.q

So what is figure.dpi used for? And I need to ask, why doesn't savefig default to the Figure dpi?

Thanks. I think I'll update my demo and maybe post it to the Wiki.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

One more thought:

John Hunter wrote:

    However, AFAIK, MPL does not have a way to set
    > the pixel size directly.

It does now. In 0.84 I added a canvas.resize(w,h) in pixels. So far
this has only been implemented in GTK*.

What about with savefig()? As long as we can set ppi there, it would be nice to set a pixel size of the Figure as well.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

Chris Barker wrote:

  I think I'll update my demo and maybe post it to the Wiki.

Done.

http://www.scipy.org/wikis/topical_software/AdjustingImageSize

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...