Gnuplot: How to increase the width of my chart

I use 'gnuplot' to draw a line plot with a dot:

set style data linespoints set xlabel "number" set ylabel "Dollars" set yrange [0:250] 

how to increase the width of my graph, so since I have more than "x", I want my graph to be larger than a rectangle, not a square?

And how to increase the spacing of my y axis? now it just draws a mark for every 50 along the y axis?

+7
source share
3 answers

It looks like you want your result to dynamically adjust in size to the data that was built. Here is the script that does this:

 #!/usr/bin/env gnuplot # don't make any output just yet set terminal unknown # plot the data file to get information on ranges plot 'data.dat' title 'My Moneys' # span of data in x and y xspan = GPVAL_DATA_X_MAX - GPVAL_DATA_X_MIN yspan = GPVAL_DATA_Y_MAX - GPVAL_DATA_Y_MIN # define the values in x and y you want to be one 'equivalent:' # that is, xequiv units in x and yequiv units in y will make a square plot xequiv = 100 yequiv = 250 # aspect ratio of plot ar = yspan/xspan * xequiv/yequiv # dimension of plot in x and y (pixels) # for constant height make ydim constant ydim = 200 xdim = 200/ar # set the y tic interval set ytics 100 # set the x and y ranges set xrange [GPVAL_DATA_X_MIN:GPVAL_DATA_X_MAX] set yrange [GPVAL_DATA_Y_MIN:GPVAL_DATA_Y_MAX] # set the labels set title 'Dollars in buckets' set xlabel 'number' set ylabel 'Dollars' set terminal png size xdim,ydim set output 'test.png' set size ratio ar set style data linespoints replot 

For example data:

 0 50 50 150 100 400 150 500 200 300 

I get the following graph:

enter image description here

This is roughly a square, as it should be (I defined 100 units in x equal to 250 units in y, and the data runs through the range [(0,200), (50,500)]). If I add another data point (400,300), the output file will be wider as expected:

enter image description here

To answer another question, you can set the ytic increment like this:

 set ytics <INCREMENT> 

The following is an example script.

+11
source

To add to the discussion here, also set size ratio ... so you can set the aspect ratio of your plot.

Here is an excerpt from help set size :

ratio causes gnuplot to attempt to create a graph with an aspect ratio (the ratio of the y-axis length to the x-axis length) within the portion of the plot specified by <xscale> and <yscale> .

The value is a negative value for another. If = -1, gnuplot tries to set the scales so that the block has the same length on both the x and y axis (for example, for geographic data). If = -2, the unit on y has twice the length of the unit in x, etc.

For this to work, you probably need to set the output driver to a reasonable size:

 set term png size 800,400 #800 pixels by 400 pixels 

or

 set term post size 8,4 #8 inches by 4 inches 

It all depends on the terminal, so it’s worth looking at the terminal’s prompt to find out which devices it uses, etc.

+3
source

set xrange [:]

set yrange [:]

Use these 2 commands to determine the "size" of your chart;)

0
source

All Articles