From: John H. <jdh...@ac...> - 2005-09-30 13:36:24
|
>>>>> "Chris" == Chris Barker <Chr...@no...> writes: Chris> Hi all, I sent pretty much this question a couple days ago, Chris> but it was tacked on to another thread, so it may have Chris> 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. Chris> This is how I thought MPL works, but it turns out I'm Chris> wrong, as the example below indicates. What have I got Chris> wrong? Chris> 1) The size of a figure is defined in length units Chris> (inches), and can be set by: Chris> Figure.set_figsize_inches( (w,h) ) Yep. Chris> 1b) The layout of the figure is defined in "figure units" Chris> 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. Chris> 2) Size of text, width of lines, etc is defined in terms of Chris> length units (points?). Yes, points. Chris> 3) When displaying to the screen, or creating an image Chris> (PNG) the pixel size of text and line widths, etc is Chris> determined by the dpi setting, which is set by: Chris> 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 Chris> The trick here is that when printing, it's natural to think Chris> in terms of inches, but when creating an image (for a web Chris> page, for instance), it is natural to think in terms of Chris> pixel size. However, AFAIK, MPL does not have a way to set Chris> 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. Chris> However, changing the dpi of the Figure doesn't seem to Chris> have any effect. What's up John? shouldn't Figure.set_dpi Chris> effect the dpi of the resulting PNG? I'm using MPL 0.84 on Chris> Linux. See the comment on savefig above. Cheers, JDH |