Menu

#4294 Package draw and plot2d Gnuplot line type interaction

None
open
nobody
5
2024-08-04
2024-04-22
No

Working with Git version ff883f3. gnuplot --version reports: gnuplot 5.4 patchlevel 2

I am working on Linux.

I noticed an interaction between the draw package and plot2d. First time I try plot2d, I see all solid lines as expected.

(%i1) plot2d (makelist (sin(k*x), k, 1, 10), [x, 0, 10]) $

Now I load the draw package and draw something, and then try the same plot2d as before.

(%i2) load (draw) $
(%i3) draw2d (rectangle ([0, 0], [10, 1])) $
(%i4) plot2d (makelist (sin(k*x), k, 1, 10), [x, 0, 10]) $

That second plot2d shows that the curves are drawn with a variety of line types, not just a solid line. Some are dashed, some dotted, etc.

I'm guessing the state of the Gnuplot process has gotten changed. If I set the plot_format to gnuplot, which executes a separate Gnuplot process instead of talking through a pipe, I see all solid lines as expected.

(%i5) plot2d (makelist (sin(k*x), k, 1, 10), [x, 0, 10], [plot_format, gnuplot]) $

Discussion

  • Jaime E. Villate

    This has to do with the fact that gnuplot_pipes keeps Gnuplot running in the background and draw changes a lot of default settings. plot2d/3d use the Gnuplot command "reset" which is supposed to reset everything to its default, but for some reason it is not working as advertised. I will try to find out whether this is a new "feature" of Gnuplot and how to do a real reset.

     
    • Robert Dodier

      Robert Dodier - 2024-08-04

      I encountered another example of this bug; the gnuplot_svg_background leaks from one plot to the next when plot_format is gnuplot_pipes, but not when it is gnuplot. See the examples for that in tests/rtest_plot.mac.

      Looking at the Gnuplot documentation (Gnuplot 5.0 for the record -- I know that's old), I see it says:

      (quote)
      The following are not affected by reset.

      set term set output set loadpath set fontpath set linetype set encoding set decimalsign set locale set psdir set fit

      Note that reset does not necessarily return settings to the state they were in at program entry, because the default values may have been altered by commands in the initialization files gnuplotrc or $HOME/.gnuplot. However, these commands can be re-executed by using the variant command reset session.
      (end quote)

      I guess we could try to capture the value of each one of those options when Maxima is launched, and then send those in addition to sending reset.

      We could also see if there is some kind of "grand reset" command to really and truly reset everything.

       
    • Robert Dodier

      Robert Dodier - 2024-08-04

      Another possibility is Gnuplot's save command, which writes current settings into a file, which can be loaded via Gnuplot's load command. I see save treats the set term value specially; one has to save save term to get the set term string! Yikes. I wonder if save has been made more comprehensible in more recent versions (I'm working with Gnuplot 5.0).

       
    • Robert Dodier

      Robert Dodier - 2024-08-04

      It appears Gnuplot doesn't provide any complete reset function. The accepted answer for this question: https://stackoverflow.com/questions/64498369/total-reset-of-a-gnuplot-session has some details about working around the issue.

       
  • Tilda A. Steiner

    Robert, I can not confirm your results. Running draw2d did not have an impact on the output of the 2nd plot2d run.

    I'm on macOS 10.15.7 and a ran your commands under Maxima 5.47.0 using Lisp SBCL 2.4.0, both, in a shell and within a TeXmacs 2.1.4 maxima session.

    On my MacPorts based system, plot2d outputs into an AquaTerm window, for reasons I do not understand. Wheras draw2d outputs correctly into a wxt-terminal, which is my standard gnuplot 5.4.8 terminal as configured in ~.gnuplot.

     

Log in to post a comment.