3

I have had trouble with the aspect ratio using gnuplot on the x11 terminal. I have tried 'set size ratio -1' and 'set size square' commands. All works well until the window is re-sized. The aspect ratio of the plot is not preserved unless the window is stretched in both directions in equal proportions.

I would like to maximize the x11 window while maintaining a square aspect ratio for the plot. Is this possible?

Also, I am using gnuplot version 4.6.5

EDIT #1:

i also have to note that im calling gnuplot from a c++ script. lets say i have an ascii file containing all the gnuplot commands called plotCOMMANDS. within my c++ script, i have the following system command to call gnuplot: gnuplot -persist plotCOMMANDS

if i was plotting within the gnuplot terminal, i could use the replot command (as suggested by Christoph). but is there a way to run the replot command within the c++ script each time the window is resized?

rolb
  • 149
  • 1
  • 9

1 Answers1

2

I think that the window content isn't updated automatically after you maximize it, but the existing plot is only rescaled to the new window size (the windows terminal has the same problem).

You must enter replot in the interactive terminal after you maximized the window. That works fine for both the x11 and the windows terminals. The hotkey e doesn't work for x11. BTW: In the upcoming version 5.0 this behavior is fixed and the window automatically replots when the canvas size is changed.

Christoph
  • 47,569
  • 8
  • 87
  • 187
  • thanks for the suggestion Christoph. i am using a c++ script to call gnuplot and i am unsure of how to incorporate the replot command. please see my edited question – rolb Aug 28 '14 at 16:00
  • 1
    You can use `bind 'e' 'replot'` to add a hotkey. Then you only need to press `e` to have the window updated. The respective change in the sources were made on 2012-09-25, but wasn't backported to the 4.6 branch. Another option would be to use the solution in http://stackoverflow.com/q/25409071/2604213 to directly start gnuplot in fullscreen. – Christoph Aug 28 '14 at 16:45
  • the `bind` solution seems to work except for one problem. im using `pause -1 'Hit return to continue: '` to keep the window interactive until the enter button is pressed. pressing 'e' does fix the scaling but the window is no longer interactive. is there anyway around this? – rolb Aug 28 '14 at 18:24
  • 1
    No, I don't know how to fix this. I've seen, that with the `wxt` the `e` hotkey works out of the box (without using `bind`) and doesn't interfere with `pause`. I tested with: `set terminal wxt; set size ratio -1; plot x; pause -1`, then changing the window size, hitting `e` and the pause is still in effect. – Christoph Aug 28 '14 at 18:35
  • thats unfortunate. i do not have the wxt terminal installed. i also tried the fullscreen solution but i get the following error: `set term x11 size *0` and it points to the asterisk as the issue. the line that gnuplot does not like is `set term x11 size @monitorSize`. i have `set macros` included – rolb Aug 28 '14 at 18:43
  • Hm, seems like that `xrandr...` solution is not very flexible. How does your output line of `xrandr` look like, which shows the current screen resolution? – Christoph Aug 28 '14 at 18:56
  • executing `xrandr` in the shell yields `*0 3840 x 1080 (1060mm x 301mm ) *50` as the first bit of information – rolb Aug 28 '14 at 19:03
  • No, thats the wrong line. Seems like you have a `*` in the Screen name. In my case, the relevant line showing the current resolution is `1680x1050 60.0*+`. Here, the `*` indicates the current resolution. – Christoph Aug 28 '14 at 19:38