2

I need to produce image with gnuplot with following guide given

width=90 mm (255 pt), pixels at 300 dpi=1063, pixels at 500 dpi=1772 , pixels at 1000 dpi=3543

How can i produce image with width=90mm and pixels=1063 for 300 dpi In gnuplot i use

set terminal pngcairo size 420,768 

But how translate x and y into required width and pixels

1 Answers1

6

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 420scale,768scale 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 = pt2mmmm2px 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.

binzo
  • 161