Menu

#1844 Multiplot: plot titles overlap in qt when set key bottom

None
closed-invalid
nobody
2016-08-23
2016-08-20
No

set multiplot
set key bottom [left|right]
plot [0:4] exp(- x) title "Cats and dogs"
replot exp(-0.2*x) title "Dogs and cats"

then "Dogs and cats" overlaps with "Cats and dogs".
Adding more plots overlaps all labels from second to last plot.
When resizing the qt window the labels clear.
When not in multiplot mode OK.
Problem both when interactive or reading commands from scripts.

gnuplot is the latest version from Ubuntu 16.04 repositories (160820):
gnuplot Version 5.0 patchlevel 3 last modified 2016-02-21,
Ubuntu 16.04,
kernel 4.4.0-34-generic x86_64

1 Attachments

Discussion

  • Bastian Märkisch

    Not a bug, but rather a misunderstanding what multiplot does. You are actually superimposing several plots on top of each other this way. Hence the result is expected.
    If you would like to plot several functions use a command list plot x title "first" , x**2 title "second".
    You can find many examples in the demos.

     
    • Konstantinos Anagnostopoulos

      Indeed, the labels don't overlap the way you suggest. There is a confusion coming from the documentation (see "help replot" )
      ...Arguments specified after a replot command will be added onto the last
      plot or splot command (with an implied ',' separator) before it is
      repeated...
      which gives the impression that it is equivalent.

      (the line "Note that in multiplot mode, replot can only reproduce the most recent
      component plot, not the full set" is not explaining this either)

      Also note that resizing the qt window clears the labels.

       
  • Hans-Bernhard Broeker

    When not in multiplot mode OK.

    So why on earth are you even using multiplot here? It makes no sense whatsoever.

    For the plot you want, multiplot is total nonense, and "replot" is not particularly applicable, either.

    What you need is more like this:

    set key bottom left
    plot [0:4] exp(- x) title "Cats and dogs", exp(-0.2*x) title "Dogs and cats"
    
     

    Last edit: Hans-Bernhard Broeker 2016-08-20
    • Konstantinos Anagnostopoulos

      Hans, I am simply showing the part of the code that creates the problem, of course to do meaningful work one adds more (embedded) plot(s).

       
      • Hans-Bernhard Broeker

        Well, that's the usual risk of posting made-up example cases instead of the ones you actually have problem with. So don't do that, then.

         
  • Ethan Merritt

    Ethan Merritt - 2016-08-20

    "replot" is not the problem. Normally it would erase your previous plot and replace it with a new one that included the original contents plus optional new content. But "set multiplot" causes it not to erase previous plots.

    We've had other recent reports of confusion about multiplot, so I'd like to revise whatever portions of the ducumentation led people astray. The start of the recently revised text for "help multiplot" now reads:

    gnuplot> help multiplot
     The command `set multiplot` places `gnuplot` in the multiplot mode,
     in which several plots are placed next to each other on the same page
     or screen window.
    

    It would be helpful if you could suggest further changes to the text or other places in the documentation that are misleading.

     
    • Konstantinos Anagnostopoulos

      Maybe in "help multiplot" add:
      Repeated use of the plot/replot command does not erase previous plots as it is normally done outside the multiplot mode.

      And in "help replot" replace

      "Note that in multiplot mode, replot can only reproduce the most recent component plot, not the full set"

      by

      "Note that in multiplot mode, replot does not erase the previous plot but, by repeating a plot command, places the new plot in the most recent component."

       
      • Ethan Merritt

        Ethan Merritt - 2016-08-20

        The first part of that is OK, thanks.

        The second part sounds weird to me. replot inside a multiplot does exactly the same thing it does outside a multiplot - makes a new plot that includes pieces of the previous plot. It does not do anything at all "in the most recent component [of the multiplot]".

         
    • Hans-Bernhard Broeker

      "replot" is not the problem.

      Actually in the case at hand it is. The root cause of the problem here is lack of understanding that

      plot a
      replot b
      

      is different from

      plot a, b
      

      "multiplot" only makes the difference more visible in this case.

       
  • Konstantinos Anagnostopoulos

    Everything is fine with the following code: (add clear before replot)
    Sorry for your time and thank you for helping me to understand it.

    set term qt 1
    set multiplot
    set key bottom
    plot [0:4] exp(- x) title "Cats and dogs"
    clear; replot exp(-0.35x) title "XXXX YYYY XXXX"
    clear; replot exp(-0.4
    x) title "Lions and bears"
    clear; replot exp(-0.7*x) title "Tigers and lillies"
    unset multiplot

     
    • Hans-Bernhard Broeker

      Everything is fine with the following code: (add clear before replot)

      No, it's not. Just because you've managed to patch around the problems you created, doesn't make it fine that you created those problems in the first place.

      Multiplot is just as pointless in this sequence as it was from the get-go, and the only reason you need "clear" is because you insist on abusing "replot" inside a multiplot.

      For "everyhting" to be "fine", that script should look like this:

      set term qt 1
      set key bottom
      plot [0:4] exp(- x) title "Cats and dogs", \
        exp(-0.35x) title "XXXX YYYY XXXX", \
        exp(-0.4x) title "Lions and bears", \
        exp(-0.7*x) title "Tigers and lillies"
      

      Generally, there's just no sane reason to use "replot" with an argument inside a saved or machine-generate gnuplot command sequence. It can always be replaced by a single plot comman with multiple graphs in it, as shown above.

       
      • Konstantinos Anagnostopoulos

        In fact it does, because I can't read my scripts, which are long and complicated, using gnuplot-mode within emacs. But of course this is not a problem of the gnuplot community.

        See: https://github.com/bruceravel/gnuplot-mode/issues/32

         
  • Konstantinos Anagnostopoulos

    For reference and in order not to confuse people of why I posted the seemingly non sensical commands, here is one of the scripts that created plots like the one I posted:

    DIM=10;NMAT=4
    tau=0.01;NTAU=10;dtau=tau/NTAU
    set autoscale

    gtitle = sprintf("Bosonic CLM D=%d N=%d {/Symbol t}= %.3f dt=%.5f",DIM,NMAT,tau,dtau);

    set term qt 1
    set title gtitle
    set multiplot
    set xlabel "{/Symbol t}"
    set ylabel "N_1 = -(1/D N)tr[(A-A^H)^2]"

    set xrange [:.6]
    plot "<grep trF,trA aaa_nocool1.out" u ($0tau):7 w l t "no cooling"
    clear;replot "<grep trF,trA aaa_cool1.out " u ($0
    tau):7 w l t "with cooling"
    set size 0.70,0.60
    set origin 0.25,0.25
    unset title;unset xlabel;unset ylabel
    set log y; set key top
    set format y "%.0l x 10^{%S}"
    set xrange [:]
    replot
    unset log;set format;set key default
    unset multiplot;unset size;unset origin

    set term qt 2
    set title gtitle
    set ylabel "(1/D N^2){/Symbol S}{i j} |A{i j}-A^H_{i j}|"
    set multiplot
    set xrange [:1]
    plot "<grep trF,trA aaa_nocool1.out " u ($0tau):8 w l t "no cooling"
    clear;replot "<grep trF,trA aaa_cool1.out " u ($0
    tau):8 w l t "with cooling"
    set size 0.70,0.60
    set origin 0.25,0.30
    unset title;unset xlabel;unset ylabel
    set log y; set key top
    set format y "%.0l x 10^{%S}"
    set xrange [:10]
    replot
    unset log;set format;set key default
    unset multiplot;unset size;unset origin

    set term qt 3
    set title gtitle
    set ylabel "No. Function Evaluations by Brent Minimization"
    plot [:] "<grep NNormCool: aaa_cool1.out" u ($0*dtau):6 w l t "with cooling"

    a_min determined by minimization

    set term qt 4
    set title gtitle
    set multiplot
    set ylabel "{/Symbol a}_{min} of norm N_1({/Symbol a})"
    set xrange [:1.3];set yrange [0.1:1.6]
    plot "<grep NNormCool: aaa_cool1.out" u ($0*dtau):7 w l t "with cooling"
    set size 0.70,0.60
    set origin 0.25,0.35
    unset title;unset xlabel;unset ylabel
    set xrange [:];set yrange[:]
    replot
    unset log;set format;set key default
    unset multiplot;unset size;unset origin

    set term qt 5
    set title gtitle
    set multiplot
    set ylabel "{/Symbol D}N = N_1(0)-N_1({/symbol a})"
    set xrange [:.1]
    plot "<grep NNormCool: aaa_cool1.out" u ($0*dtau):($9-$8) w l t "with cooling"

    embedded plot:

    set size   0.70,0.60
    set origin 0.25,0.30
    unset title;unset xlabel;unset ylabel
    set log y; set key top
    set format y "%.0l x 10^{%S}"
    set xrange [:10]
    replot
    unset log;set format;set key default
    

    unset multiplot;unset size;unset origin

    set term qt 6
    unset title
    set xlabel "{/Symbol a}";set ylabel "N_1({/Symbol a})"
    set xrange [-10:20]
    filter(i,f) = sprintf("awk '/plotNNorm/&& $3==%d{print $4,$5}' %s",i,f)
    adata (i,f) = "<".filter(i,f)
    acom (i,f,n) = system(sprintf("%s|awk -v n=%d 'NR==(n+1){print $1}'",filter(i,f),n))
    set multiplot title gtitle layout 2,2

    file = "aaa_cool1.out";

    iter = 1 # iteration number to filter out plot
    data = adata(iter,file);stats data using 1:2 nooutput;nmin = int(STATS_index_min_y);norm_min = STATS_min_y;amin = acom(iter,file,nmin);
    iter1=iter
    data1=data
    amin1=amin
    plot data1 w l title sprintf("{/Symbol t}=%.2f cool\na_{min}=%.4s",iter1*tau,amin1)

    iter = 10 # iteration number to filter out plot
    data = adata(iter,file);stats data using 1:2 nooutput;nmin = int(STATS_index_min_y);norm_min = STATS_min_y;amin = acom(iter,file,nmin);
    iter2=iter
    data2=data
    amin2=amin
    plot data2 w l title sprintf("{/Symbol t}=%.2f cool\na_{min}=%.4s",iter2*tau,amin2)

    iter = 100 # iteration number to filter out plot
    data = adata(iter,file);stats data using 1:2 nooutput;nmin = int(STATS_index_min_y);norm_min = STATS_min_y;amin = acom(iter,file,nmin);
    iter3=iter
    data3=data
    amin3=amin
    set format y "%.1t 10^{%T}"
    plot data3 w l title sprintf("{/Symbol t}=%.2f cool\na_{min}=%.4s",iter3*tau,amin3)

    iter = 500 # iteration number to filter out plot
    data = adata(iter,file);stats data using 1:2 nooutput;nmin = int(STATS_index_min_y);norm_min = STATS_min_y;amin = acom(iter,file,nmin);
    iter4=iter
    data4=data
    amin4=amin
    set format y "%.1t 10^{%T}"
    plot data4 w l title sprintf("{/Symbol t}=%.2f cool\na_{min}=%.6s",iter4*tau,amin4)
    unset multiplot;unset format

    set term qt 7
    unset title
    set xlabel "{/Symbol a}";set ylabel "N_1({/Symbol a})"
    set xrange [-10:20]
    filter(i,f) = sprintf("awk '/plotNNorm/&& $3==%d{print $4,$5}' %s",i,f)
    adata (i,f) = "<".filter(i,f)
    acom (i,f,n) = system(sprintf("%s|awk -v n=%d 'NR==(n+1){print $1}'",filter(i,f),n))
    set multiplot title gtitle layout 2,2

    file = "aaa_nocool1.out";

    set xrange [-5:6]
    iter = 1 # iteration number to filter out plot
    data = adata(iter,file);stats data using 1:2 nooutput;nmin = int(STATS_index_min_y);norm_min = STATS_min_y;amin = acom(iter,file,nmin);
    iter1=iter
    data1=data
    amin1=amin
    plot data1 w l title sprintf("{/Symbol t}=%.2f no cool\na_{min}=%.4s",iter1*tau,amin1)

    set xrange [-10:10]
    iter = 10 # iteration number to filter out plot
    data = adata(iter,file);stats data using 1:2 nooutput;nmin = int(STATS_index_min_y);norm_min = STATS_min_y;amin = acom(iter,file,nmin);
    iter2=iter
    data2=data
    amin2=amin
    plot data2 w l title sprintf("{/Symbol t}=%.2f no cool\na_{min}=%.4s",iter2*tau,amin2)

    set xrange [-10:20]
    iter = 100 # iteration number to filter out plot
    data = adata(iter,file);stats data using 1:2 nooutput;nmin = int(STATS_index_min_y);norm_min = STATS_min_y;amin = acom(iter,file,nmin);
    iter3=iter
    data3=data
    amin3=amin
    set format y "%.1t 10^{%T}"
    plot data3 w l title sprintf("{/Symbol t}=%.2f no cool\na_{min}=%.4s",iter3*tau,amin3)

    iter = 500 # iteration number to filter out plot
    data = adata(iter,file);stats data using 1:2 nooutput;nmin = int(STATS_index_min_y);norm_min = STATS_min_y;amin = acom(iter,file,nmin);
    iter4=iter
    data4=data
    amin4=amin
    set format y "%.1t 10^{%T}"
    plot data4 w l title sprintf("{/Symbol t}=%.2f no cool\na_{min}=%.6s",iter4*tau,amin4)
    unset multiplot;unset format;unset xrange

     

    Last edit: Konstantinos Anagnostopoulos 2016-08-21
  • Ethan Merritt

    Ethan Merritt - 2016-08-23
    • status: open --> closed-invalid
    • Group: -->
    • Priority: -->
     

Log in to post a comment.