[Matplotlib-users] Why is canvas.print_figure to a png reduce the real size of my image

Jody Klymak jklymak at uvic.ca
Fri Oct 20 20:32:57 EDT 2017


Fair enough.  Just to be safe, just do dpi=600!  It’ll be big, but...

Cheers,   Jody

> On Oct 20, 2017, at  16:02 PM, David Goldsmith <eulergaussriemann at gmail.com> wrote:
> 
> OK, thanks for your help.
> 
> What I’m doing is somewhere in between: I’m making my own “fractals,” “from scratch”; so if im going to the trouble of computing a 3600x2400 grid so that I can have a 300 DPI image end up being 12x8, that’s what I want to end up with (i don’t want to compute any more than I have to, but by the same token, I want to see everything I’m computing).  Anyway, i’ll see if that does what I’m after and reply again if not.  (Though I’d still like to know what’s going on under the hood, so that I can exploit that if I choose.)
> 
> Thanks again!
> 
> DLG
> 
> On Fri, Oct 20, 2017 at 3:44 PM Jody Klymak <jklymak at uvic.ca <mailto:jklymak at uvic.ca>> wrote:
> 
> 
>> On 20 Oct 2017, at  15:33 PM, David Goldsmith <eulergaussriemann at gmail.com <mailto:eulergaussriemann at gmail.com>> wrote:
>> 
>>  But mostly, I’d just like to understand what’s going on, because what’s happening now makes absolutely no sense to me whatsoever.
> 
> Ha!  
> 
> I think you are approaching this from the point of view of an image processing library or something like Photoshop where you want your image to be 6x8 and 300 dpi, and you expect 1800x2400 pixels.  
> 
> Thats not *really* what matplotlib is for. It really is for presentation of scientific data.  So, I have a 500x600 matrix of data, I may use `imshow` to plot it up, but most people don’t care about the dpi of those pixels, so they will just set the dpi to something that shows all the data clearly.  Much more important is the ability to have axis labels, annotations, etc.  
> 
> Its not to say that you can’t be careful and get what you want.  I think what I sent you is pretty close.  But the library is not trying to conserve pixels.  
> 
> Anyway, what I sent should be clear enough.  I think what you were missing was setting the figure size to the size you wanted before trying to draw on it.
> 
> Cheers,   Jody
> 
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20171020/5d8b519a/attachment-0001.html>


More information about the Matplotlib-users mailing list