matshow unequal element sizes

Hi all,

I am trying to draw a heatmap using matshow, which I then save as a PDF.
If I then zoom in in the PDF, I notice that different rows have different sizes, and different columns have different sizes. It seems that some rows/columns have twice the height/width as other rows/columns.
Attached is a screenshot of part of the PDF after zooming in.
Is there some way to force all rows / columns to have the same height/width?

Best,
-Michiel.

image.PNG

By default (when interpolation="nearest") matplotlib is performing nearest neighbor interpolation on the image to the request PDF dpi before storing it in the file. This results in rows and columns of unequal size because the ratio from the original image to the destination resolution is likely not integral.

You can set interpolation="none", which will pass the original image as-is on to the file, but then we can't control the interpolation mode (since there's no way to tell the PDF viewer what sort of interpolation to perform), so that (usually) will result in bicubic interpolation, which is probably not what you want.

Mike

···

On 06/06/2013 05:52 AM, Michiel de Hoon wrote:

Hi all,

I am trying to draw a heatmap using matshow, which I then save as a PDF.
If I then zoom in in the PDF, I notice that different rows have different sizes, and different columns have different sizes. It seems that some rows/columns have twice the height/width as other rows/columns.
Attached is a screenshot of part of the PDF after zooming in.
Is there some way to force all rows / columns to have the same height/width?

Best,
-Michiel.

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j

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

pdf's because it saves the polygons. You might need some tweaking to get
it exactly right, but at least the pdf viewer won't smudge it all out.

Cheers!
Ben Root

···

On Thu, Jun 6, 2013 at 10:14 AM, Michael Droettboom <mdroe@...86...> wrote:

By default (when interpolation="nearest") matplotlib is performing
nearest neighbor interpolation on the image to the request PDF dpi before
storing it in the file. This results in rows and columns of unequal size
because the ratio from the original image to the destination resolution is
likely not integral.

You can set interpolation="none", which will pass the original image as-is
on to the file, but then we can't control the interpolation mode (since
there's no way to tell the PDF viewer what sort of interpolation to
perform), so that (usually) will result in bicubic interpolation, which is
probably not what you want.

Mike

From experience, it seems that pcolor() or pcolormesh() works best for

Thanks! Using pcolor indeed solved the problem. Now my rows and columns are all nice and even.

Best,
-Michiel.

···

From: Benjamin Root <ben.root@…1304…>
To: Michael Droettboom <mdroe@…86…>
Cc: Matplotlib Users matplotlib-users@lists.sourceforge.net
Sent: Friday, June 7, 2013 1:40 AM
Subject: Re: [Matplotlib-users] matshow unequal element sizes

On Thu, Jun 6, 2013 at 10:14 AM, Michael Droettboom <mdroe@…2662…> wrote:

  By default (when

interpolation=“nearest”) matplotlib is performing nearest neighbor
interpolation on the image to the request PDF dpi before storing
it in the file. This results in rows and columns of unequal size
because the ratio from the original image to the destination
resolution is likely not integral.

  You can set interpolation="none", which will pass the original

image as-is on to the file, but then we can’t control the
interpolation mode (since there’s no way to tell the PDF viewer
what sort of interpolation to perform), so that (usually) will
result in bicubic interpolation, which is probably not what you
want.

  Mike

From experience, it seems that pcolor() or pcolormesh() works best for pdf’s because it saves the polygons. You might need some tweaking to get it exactly right, but at least the pdf viewer won’t smudge it all out.

Cheers!
Ben Root


How ServiceNow helps IT people transform IT departments:

  1. A cloud service to automate IT design, transition and operations
  2. Dashboards that offer high-level views of enterprise services
  3. A single system of record for all IT processes
    http://p.sf.net/sfu/servicenow-d2d-j

Matplotlib-users mailing list
Matplotlib-users@…2982…e.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users