|
From: Nikolaus R. <Nik...@ra...> - 2012-10-11 14:00:45
|
Hello, I'm confused by the dpi property of figures that can be set in matplotlibrc or passed to pyplot.figure(). It seems to me that dpi is really a property of the backend, not the figure, and the only place to specify it ought to be when saving into a bitmap file. For example, when showing a figure on the screen, I really want matplotlib to use the physical dpi of the monitor rather than any default value. When saving the figure in some vector graphics format, I don't see what the meaning of the dpi is at all. Am I missing something? Best, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C |
|
From: Damon M. <dam...@gm...> - 2012-10-11 14:11:23
|
On Thu, Oct 11, 2012 at 4:00 PM, Nikolaus Rath <Nik...@ra...> wrote: > When saving the figure in some vector graphics format, I > don't see what the meaning of the dpi is at all. Sure, I use `dpi=` all the time for vector formats. Purely because when you make calls to `imshow`, you get a rasterised image embedded in a figure with vector text and tickmarks and labels, for example. -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom |
|
From: Nikolaus R. <Nik...@ra...> - 2012-10-11 18:39:46
|
Damon McDougall <dam...@pu...> writes: > On Thu, Oct 11, 2012 at 4:00 PM, Nikolaus Rath <Nik...@pu...> wrote: >> When saving the figure in some vector graphics format, I >> don't see what the meaning of the dpi is at all. > > Sure, I use `dpi=` all the time for vector formats. Purely because > when you make calls to `imshow`, you get a rasterised image embedded > in a figure with vector text and tickmarks and labels, for example. 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. Best, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C |
|
From: Jae-Joon L. <lee...@gm...> - 2012-10-12 01:35:13
|
On Fri, Oct 12, 2012 at 3:39 AM, Nikolaus Rath <Nik...@ra...> wrote: > 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. -JJ |
|
From: Nikolaus R. <Nik...@ra...> - 2012-10-12 13:08:08
|
Jae-Joon Lee <lee...@pu...> writes: > On Fri, Oct 12, 2012 at 3:39 AM, Nikolaus Rath <Nik...@pu...> wrote: >> 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 -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C |
|
From: Jae-Joon L. <lee...@gm...> - 2012-10-19 04:49:04
|
> 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 |
|
From: Pierre H. <pie...@cr...> - 2012-10-19 15:11:29
Attachments:
signature.asc
PyQt_screen_resolution.py
|
Hi, Le 19/10/2012 06:48, Jae-Joon Lee a écrit : > 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 |