Menu

#3650 Set the datafile separator for gnuplot in draw

None
closed
None
5
2020-08-22
2020-08-20
FR3141
No

Parametric plots using draw2d and the default screen terminal funtion normally.

draw2d(terminal=screen, parametric(sin(t),cos(t),t,0,2*%pi));

But whenever the terminal is set to an image type the parametric plot fails:

draw2d(terminal=pngcairo, parametric(sin(t),cos(t),t,0,2%pi));
draw2d(terminal=png, parametric(sin(t),cos(t),t,0,2
%pi));
draw2d(terminal=jpg, parametric(sin(t),cos(t),t,0,2%pi));
draw2d(terminal=eps, parametric(sin(t),cos(t),t,0,2
%pi));

Attached are the image files resulting from the above commands.

This parametric plot failure causes Wxmaxima, the graphical front end to maxima, to also fail with all parametric plots bacause wxmaxima will first create a PNG image for any plot.

I am using maxima-5.44.0 and gcl-2.6.12.

4 Attachments

Discussion

  • Kris Katterjohn

    Kris Katterjohn - 2020-08-20

    Thank you for the report. I'm not able to reproduce this behavior using 5.43.2 or git HEAD. For the former I used ECL and the latter I used SBCL, both on OpenBSD.

    I appreciate you telling us your Maxima and lisp version, but could you also post the output of build_info() ?

    It wasn't quite clear from your report: did you also try this without wxMaxima or any other frontend? It would be useful to eliminate wxMaxima as a potential cause. If this behavior only occurs in wxMaxima, then this problem should be reported there instead.

    It could also be helpful if you could try this using a different lisp implementation (such as SBCL or ECL, but there are others). Are you able to try this? This is perhaps less important than trying it outside of wxMaxima, but this is also a useful thing to know.

     
  • FR3141

    FR3141 - 2020-08-20

    I first noticed this when using wxmaxima, but to try and debug I used commands from within maxima and found that in maxima the parametric plot fails when the terminal is set to any image type. So the fault is within maxima.

    build_info();

    Maxima version: "5.44.0"
    Maxima build date: "2020-08-11 14:50:42"
    Host type: "x86_64-unknown-linux-gnu"
    Lisp implementation type: "GNU Common Lisp (GCL)"
    Lisp implementation version: "GCL 2.6.12"
    User dir: "/root/.maxima"
    Temp dir: "/tmp"
    Object dir: "/root/.maxima/binary/5_44_0/gcl/GCL_2_6_12"
    Frontend: false

    It will take me some time to try this with a different Lisp but in a few days I may be able to do it.

    Is there any way to intercept the exact command being sent from maxima to gnuplot?

     
  • Kris Katterjohn

    Kris Katterjohn - 2020-08-20

    OK, thanks. That's helpful.

    I don't use draw much personally, but let's see if I can still help here.
    It appears that the temporary files used for plotting are deleted when Maxima exits.

    So after you start up Maxima and attempt to draw an image, take a look in your /tmp directory -- without quitting Maxima first. In /tmp you should see two files named maxoutXXX.gnuplot and dataXXX.gnuplot where XXX is the process ID for that Maxima process.

    I'm not very familiar with the plot/draw code and I don't have time to dig around right now, but to start I think those files will help you determine whether or not Maxima is sending some bogus stuff out to gnuplot. Maybe someone else can help more here.

     
  • FR3141

    FR3141 - 2020-08-20

    I suspect that the problem may be in gnuplot.

    The datafile and the gnuplot command file produced by maxima are identical for both "terminal=png" and "terminal=screen." These files are attached.

    The maxima datafile, "data.gnuplot," contains the correct points for a parametric circle, but if I plot this file with gnuplot the result is the same linear graph as shown in my original post.

    I am using the latest gnuplot-5.4.

    If anyone is using an earlier gnuplot version, please plot the "data.gnuplot" file directly in gnuplot using the commands:

    unset parametric
    plot "data.gnuplot" with lines

    This should give a circle. If so, then the fault is the latest gnuplot-5.4.

     
  • FR3141

    FR3141 - 2020-08-20

    SOLVED

    The problem is traced to the "datafile separator" setting in gnuplot.

    Maxima produces a datafile with fields separated by whitespace. My gnuplot config file has
    the datafile separator set to a comma, ",".

    However, this was never a problem with maxima previously.

    Perhaps maxima should include the gnuplot command "set datafile separator whitespace"
    in its exported gnuplot command file. This would override any user-specified value and ensure
    that the datafile would be properly parsed.

     
  • Kris Katterjohn

    Kris Katterjohn - 2020-08-20
    • status: open --> closed
     
  • Kris Katterjohn

    Kris Katterjohn - 2020-08-20

    I just gave it a quick try using your data.gnuplot file and your gnuplot commands, and I get the expected circle using gnuplot 5.2.

    $ uname -rs
    OpenBSD 6.7
    
    $ gnuplot --version
    gnuplot 5.2 patchlevel 7
    

    Based on this and your comments, this does not appear to be a bug in Maxima. I'm closing this report.

     
  • Kris Katterjohn

    Kris Katterjohn - 2020-08-20
    • summary: Parametric Plot Fails with Any Image Terminal --> Set the datafile separator for gnuplot
    • status: closed --> open
     
  • Kris Katterjohn

    Kris Katterjohn - 2020-08-20

    I just noticed that we had posted within a few seconds of each other. I don't use gnuplot directly much but your idea to set the datafile separator sounds reasonable. I'll try to look into that within the next few days when I get a chance.

     
  • FR3141

    FR3141 - 2020-08-21

    Thanks for your information about the location of the maxima export files. Without those files I wouldn't have found the source of the problem/

    The default datafile separator in gnuplot is whitespace. A short time ago I had been using gnuplot with CSV data files and I became tired of always resetting the separator to a comma. I therefore changed my gnuplot config file to set the separator to a comma. It was likely at this time that the maxima/wxmaxima parametric plot failure was first noticed.

    When maxima calls gnuplot the gnuplot config file is read and because the maxima data is separated by whitespace gnuplot cannot properly read the datafile. It will just plot the first column.

    Because it is likely that many gnuplot users will change the datafile separator from the whitespace it would be prudent for maxima to include a set to whitespace in its gnuplot command export.

     
  • Kris Katterjohn

    Kris Katterjohn - 2020-08-22
    • summary: Set the datafile separator for gnuplot --> Set the datafile separator for gnuplot in draw
    • assigned_to: Kris Katterjohn
     
  • Kris Katterjohn

    Kris Katterjohn - 2020-08-22
    • status: open --> closed
     
  • Kris Katterjohn

    Kris Katterjohn - 2020-08-22

    Fixed with commit [e58c8d].

    Thank you for your help. I followed your advice and set the datafile separator to whitespace in the maxout.gnuplot file.

    I reproduced the problem by setting the separator to a comma in my gnuplot configuration file and as expected setting the separator in maxout.gnuplot fixes the problem for me.

     

    Related

    Commit: [e58c8d]


Log in to post a comment.

MongoDB Logo MongoDB