Skip to main content
The discussion in the comments are incorporated.
Source Link
binzo
  • 161
  • 2

Solution 1

I will assume that you have already created a figure that is just the right size of 420x768. To generate a PNG image with a width of 1063 pixels (90mm at 300dpi) without changing the look of the figure, set it up as follows,

scale = 1063.0/420.0

set terminal pngcairo size 420*scale,768*scale fontscale scale linewidth scale pointscale scale

# PLOT HERE

In this setting, the width and height of the figure are multiplied by 1063.0/420.0 = 2.53, and the font size, line width, and point size are scaled by the same factor.

Solution 2

If you want to build a diagramfigure from scratch with a given DPI, how about the following terminal settings,

dpi = 300 ## dpi (variable)
width = 90 ## mm (variable)
height = 164.5 ## mm (variable)

in2mm = 25.4 # mm (fixed)
pt2mm = 0.3528 # mm (fixed)

mm2px = dpi/in2mm
ptscale = pt2mm*mm2px
round(x) = x - floor(x) < 0.5 ? floor(x) : ceil(x)
wpx = round(width * mm2px)
hpx = round(height * mm2px)

set terminal pngcairo size wpx,hpx fontscale ptscale linewidth ptscale pointscale ptscale

# PLOT HERE

height is calculated using 764.0/420.0*90 to keep aspect ratio of original figure.

Solution 1

I will assume that you have already created a figure that is just the right size of 420x768. To generate a PNG image with a width of 1063 pixels (90mm at 300dpi) without changing the look of the figure, set it up as follows,

scale = 1063.0/420.0

set terminal pngcairo size 420*scale,768*scale fontscale scale linewidth scale pointscale scale

# PLOT HERE

In this setting, the width and height of the figure are multiplied by 1063.0/420.0 = 2.53, and the font size, line width, and point size are scaled by the same factor.

Solution 2

If you want to build a diagram from scratch with a given DPI, how about the following terminal settings,

dpi = 300 ## dpi (variable)
width = 90 ## mm (variable)
height = 164.5 ## mm (variable)

in2mm = 25.4 # mm (fixed)
pt2mm = 0.3528 # mm (fixed)

mm2px = dpi/in2mm
ptscale = pt2mm*mm2px
round(x) = x - floor(x) < 0.5 ? floor(x) : ceil(x)
wpx = round(width * mm2px)
hpx = round(height * mm2px)

set terminal pngcairo size wpx,hpx fontscale ptscale linewidth ptscale pointscale ptscale

# PLOT HERE

Solution 1

I will assume that you have already created a figure that is just the right size of 420x768. To generate a PNG image with a width of 1063 pixels (90mm at 300dpi) without changing the look of the figure, set it up as follows,

scale = 1063.0/420.0

set terminal pngcairo size 420*scale,768*scale fontscale scale linewidth scale pointscale scale

# PLOT HERE

In this setting, the width and height of the figure are multiplied by 1063.0/420.0 = 2.53, and the font size, line width, and point size are scaled by the same factor.

Solution 2

If you want to build a figure from scratch with a given DPI, how about the following terminal settings,

dpi = 300 ## dpi (variable)
width = 90 ## mm (variable)
height = 164.5 ## mm (variable)

in2mm = 25.4 # mm (fixed)
pt2mm = 0.3528 # mm (fixed)

mm2px = dpi/in2mm
ptscale = pt2mm*mm2px
round(x) = x - floor(x) < 0.5 ? floor(x) : ceil(x)
wpx = round(width * mm2px)
hpx = round(height * mm2px)

set terminal pngcairo size wpx,hpx fontscale ptscale linewidth ptscale pointscale ptscale

# PLOT HERE

height is calculated using 764.0/420.0*90 to keep aspect ratio of original figure.

Source Link
binzo
  • 161
  • 2

Solution 1

I will assume that you have already created a figure that is just the right size of 420x768. To generate a PNG image with a width of 1063 pixels (90mm at 300dpi) without changing the look of the figure, set it up as follows,

scale = 1063.0/420.0

set terminal pngcairo size 420*scale,768*scale fontscale scale linewidth scale pointscale scale

# PLOT HERE

In this setting, the width and height of the figure are multiplied by 1063.0/420.0 = 2.53, and the font size, line width, and point size are scaled by the same factor.

Solution 2

If you want to build a diagram from scratch with a given DPI, how about the following terminal settings,

dpi = 300 ## dpi (variable)
width = 90 ## mm (variable)
height = 164.5 ## mm (variable)

in2mm = 25.4 # mm (fixed)
pt2mm = 0.3528 # mm (fixed)

mm2px = dpi/in2mm
ptscale = pt2mm*mm2px
round(x) = x - floor(x) < 0.5 ? floor(x) : ceil(x)
wpx = round(width * mm2px)
hpx = round(height * mm2px)

set terminal pngcairo size wpx,hpx fontscale ptscale linewidth ptscale pointscale ptscale

# PLOT HERE