plotterminalgnuplot

How to keep previous plots and windows in Gnuplot?


I have some problems of using gnuplot. I've just begun with it.

  1. What is the command for keeping the previous plot when I plot new data? Do I have to plot the old data and the new data at the same time?

  2. What is the command for opening a new window while keeping the old ones? Do I have to set the window's id by using, e.g.,

    set terminal wxt 3
    

    before each plot?

Can anyone give me some help or some good references?


Solution

  • You already wrote the answers of your questions.

    1.: You can use the replot command:

    plot sin(x)
    replot cos(x)
    

    but this just expands to

    plot sin(x), cos(x)
    

    So, it replots all data and does not just add the cos(x).

    2.: Yes, you can also switch between the windows to update the plots. But note that settings like ranges and labels are not stored per window / plot, but globally. If they are different for different plots, you have to change them every time.

    You may also have a look at "set multiplot" to put several plots on one window / picture. But it is not so nice for interactive plotting, as you will notice. Also, output terminals supporting multiple pages like pdfcairo will add a new page for each plot.