Jae-Joon Lee <lee.j.joon-Re5JQEeQqe8AvxtiuMwx3w@...1455...> writes:
matplotlib actually rescales the raw imshow data when saving to a vector
format? Why is that? I think it should embed the bitmap with full
resolution in the vector file and rely on the consumer of the vector
file to scale it to whatever resolution is supported by the display
device.
imshow supports interpolation and that's why rasterization comes in.
If you turn off interpolation (w/ interpolation="none"), the original
image will be embedded. Of course dpi has no meaning in this case.
However, I agree with you that dpi should be a property of the backend
only, not the figure. But I am not sure if this can be fixed soon. It
will be difficult and will take lots of effort I think.
Yeah, that's what I feared. But in the mean time, are there any best
practices to minimize undesired effects like the one above? For example,
are there any other functions that need special parameters to not raster
their output when writing to a vector format? And is there a way to get
a figure on the screen with the right size when I don't know what dpi
the monitor is running with?
Best,
-Nikolaus
···
On Fri, Oct 12, 2012 at 3:39 AM, Nikolaus Rath <Nikolaus-BTH8mxji4b0@...1836...455...> wrote:
--
»Time flies like an arrow, fruit flies like a Banana.«
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
Yeah, that's what I feared. But in the mean time, are there any best
practices to minimize undesired effects like the one above? For example,
are there any other functions that need special parameters to not raster
their output when writing to a vector format? And is there a way to get
a figure on the screen with the right size when I don't know what dpi
the monitor is running with?
As I said, if you use interpolation="none" with your inshow, the
original image will be sent to the backends.
Figuring out the dpi of the screen, I have no clue at this moment.
Maybe this is something a gui expert can answer.
Regards,
-JJ
Hi,
Figuring out the dpi of the screen, I have no clue at this moment.
Maybe this is something a gui expert can answer.
I'm certainly not a gui expert, but as a PyQt user, I know screen
resolution is indeed Python-accessible with PyQt. (I guess other
toolkits provide their own methods)
I've made a quick script that prints the screen X and Y resolution
(requires PyQt). Reference links to PyQt API docs are included.
In my case, it's 96 dpi, and that what I use in my matplotlibrc file for
the "figure.dpi" property. But I use a higher value (say 150) for
"savefig.dpi" so that I get better resolution when saving PNG images.
I agree with Nikolaus that the dpi value for displaying figures would be
better get by the software, if possible. Maybe a property like
figure.dpi='auto' should activate such a behavior. But this would
require many code duplicates, one for each gui toolkit.
Best,
Pierre
PyQt_screen_resolution.py (638 Bytes)
···
Le 19/10/2012 06:48, Jae-Joon Lee a écrit :