1

I want to make the border a strict square, not a rectangle, here is my picture with the code, how should I modify it? f9 I tried adding the command set terminal pngcairo size 400,400 enhanced square but it gives an error and doesn't make my box square.

set tmargin at screen 0.995;    # top and right usually close to 1
set rmargin at screen 0.995;
set bmargin at screen 0.05;
set lmargin at screen 0.07;

set xr[0:0.24]
set yr[0:0.24]
set xtics border offset   0,0.4 0,0.05,0.2
set ytics border offset   0.8,0 0,0.05,0.2
set xlabel 'B' offset 0,3
set ylabel 'C' offset 9,0

set key at 0.22,0.1 width 1 maxrows 4

plot '-' w p ps 2 pt 11 lc 8 title "D",\
     '-' w p ps 2 pt 7 lc 8 title "A",\
     '-' w p ps 2 pt 9 lc 8 title "A", \
     '-' w p ps 2 pt 13 lc 8 title "A",\
     '-' w p ps 2 pt 10 lc 8 title "A",\
     '-' w p ps 2 pt 6 lc 8 title "A",\
     '-' w p ps 2 pt 8 lc 8 title "A",\
     '-' w p ps 2 pt 12 lc 8 title "A",\
     x dashtype 2 lc 8 lw 3 notitle

0.208555 0.204212
e
0.108604 0.107899
e
0.055720 0.055651
e
0.037514 0.037498
e
0.208555 0.230125
e
0.108604 0.115062
e
0.055720 0.057531
e
0.037514 0.038354
e

f10 f11

  • what is your terminal? wxt, qt, pngcairo, cairolatex, or other... ? – theozh Oct 28 '22 at 11:34
  • @theozh My terminal should be qt, I took a screenshot of gnuplot in the question. Thank you very much! – Zhao Dazhuang Oct 28 '22 at 11:39
  • for fixed graph size and variable canvas size, you also might want to check this question: https://stackoverflow.com/q/68269120/7295599 – theozh Oct 28 '22 at 11:39
  • @theozh Thanks, I saw your answer, I'll try to fix this myself – Zhao Dazhuang Oct 28 '22 at 11:42
  • What you could do manually: your graph with large blank space on the right has a size of 640x480 pixels. So, set the canvas/terminal size e.g. to 512x480 pixels. This should reduce the blank space (for this specific plot). Of course, an automated way would be preferred. – theozh Oct 28 '22 at 11:54

1 Answers1

1

Check the manual and read help size.

Syntax: 

      set size {{no}square | ratio <r> | noratio} {<xscale>,<yscale>}

If you want the graph area (not the canvas) to be a square add a line:

set size square

If you want the x- and y-axes the same scale, i.e. y=x will appear as a 45° line (but the graph area will not necessarily be a square), add:

set size ratio -1
theozh
  • 22,244
  • 5
  • 28
  • 72
  • Thank you so much, you helped me again. Excuse me, after entering this command ` set tmargin at screen 0.995; set rmargin at screen 0.995;`don t work, it will leave a large blank around it. How should I modify this? – Zhao Dazhuang Oct 28 '22 at 10:26
  • @ZhaoDazhuang you either can have fixed margins **or** let gnuplot force the graph to be squared but not both. What do you want? A square graph area with minimal space around it? Then you have to adjust the canvas. But depending on the data, x,y-labels you don't know beforehand how much space you will need around the graph area. I guess this can also be done but requires a bit more effort. So, you are asking for an adaptive canvas? Or should the canvas be fixed in size and maybe squared as well? – theozh Oct 28 '22 at 10:34
  • Thank you, it turns out to be so troublesome, then I will tell the teacher, it should not be necessary – Zhao Dazhuang Oct 28 '22 at 10:40
  • @ZhaoDazhuang just explain what you want. Edit your question and show the graph with the large blank around it and say what you want to change. Which quantities should be fixed and which are variable (canvas size, graph size, graph ratio, etc.)? As long as the settings are not contradictory, I am sure it can be done with gnuplot. – theozh Oct 28 '22 at 10:49
  • That is too much trouble for you. I updated the question. You can see that there is a large blank on the right border of the last picture. I want to cut this blank and keep it only as narrow as the upper border. Of course, it would be better if you modify the gnu file you helped me before, because I actually use your gnu file, thank you very much! – Zhao Dazhuang Oct 28 '22 at 11:34