Skip to content

Proposal: user-friendly DPI setting. #742

@ma-laforge

Description

@ma-laforge

Currently, Plots.jl specifies (mostly) all of its dimenensions in pixels. For example, line widths & plot size are specified in pixels.

This solution is perfect for rending images on screen, because the user can really visualize how things will end up looking on their screen.

The problem is when people want to generate high-resolution "bitmap" images (typically .png).

Solution:

  1. Assume all dimensions are in typography "points" (1/72")- instead of pixels.
  2. Anything that gets rendered to screen somehow gets rendered using a "dpi" value of 72 - irrespective of the DPI value assigned to the plot. This way, users gets what they expect on screen - no surprises. A width of 1 shows up as 1 pixel wide on the screen!
  3. When the user saves to a bitmap format, that's when they actually get to apply the dpi value in a way that is useful:
png("MyHighResPicture.png", dpi=4*72) #4*4=16x more pixels than on screen!

EDIT:
Maybe screen "dpi" should be machine dependent or user-configurable (.juliarc.jl?). 1 pixel lines & small text apparently become very difficult to see/read when pixels are physically very small (see issue with retina displays #739).

I am not too keen on using the os-supplied "dpi" value though - because Microsoft's supposed "96dpi screens" would end up with fractional line widths & result in strange pixel counts.

Comments:

  • Since the meaning of plot size is also in "points" (no longer pixels), that means the number of pixels in the image would also scale with dpi.
  • I'm not sure how to structure Plots.jl to do this... But I think this solution would be very intuitive for most people - because it would actually do what they expect!
  • As a side note, the dpi value would not affect the output to vector graphics (like .svg) because those would get rendered exactly the same as what you see on screen... only with an "infinite" resolution!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions