gnuplot

Gnuplot : How to specify the graph width in pixels?


I would like to plot the output of a dataset so that there is one pixel per sample, on the X axis. e.g. if I have a dataset of 500 samples then I would like to ensure that the X axis is 500 pixels wide. Does anyone know how to do this with Gnuplot?


Solution

  • This request makes sense only for bitmap terminals. In order to get a plotting area with a fixed size, you must both set a respective terminal size and fixed margins. The following script gives a plotting area of 500px width. This includes the 1px thick border lines, which are also part of the plotting area, what you can see, with set border back:

    set terminal pngcairo size 600,500
    set lmargin at screen 80.0/600
    set rmargin at screen 579.0/600
    
    set border back
    set output 'output.png'
    plot x