Problem with GNUPLOT and a graph

Help
Bissmark
2013-04-18
2013-05-07
  • Bissmark
    Bissmark
    2013-04-18

    Hey guys,

    I'm new to gnuplot and have this f*g problem that I don't manage to solve. There is somme strange value on my graph that I don't manage to explain. Please Help

    !(/Users/theophilewerle/Downloads/TN/capture.png)
    !(/Users/theophilewerle/Downloads/TN/Capture2.png)

     
  • Dave Clarke
    Dave Clarke
    2013-04-18

    Those images didn't attach, try again. Also include your plotting script and data aand we'll be able to help.

     
  • Bissmark
    Bissmark
    2013-04-18

    Sorry about that

     
    Attachments
  • Bissmark
    Bissmark
    2013-04-18

    And the scipt,

     
    Attachments
  • Ethan Merritt
    Ethan Merritt
    2013-04-18

    Please give your gnuplot version when reporting a problem. That output looks like it may be due to a bug that was present specifically in gnuplot version 4.6.0, but was fixed for version 4.6.1 and later.
    See https://sourceforge.net/p/gnuplot/bugs/1167/

     
  • Bissmark
    Bissmark
    2013-04-24

    Sorry for the the delay, I had some exams to take....
    Thanks for the advise, I update the gnuplot to 4.6.7 but I still have the problem...
    Any Idea ?

     
    Attachments
  • Dave Clarke
    Dave Clarke
    2013-04-24

    Can you send the gnuplot script you used. If you are typing commands directly into gnuplot interactive then after plotting use the command: save 'myscript.plot'

     
  • Bissmark
    Bissmark
    2013-04-24

    I use it in a java application so in a java Class. Here is the code:

    try
    {
    BufferedWriter out = new BufferedWriter(new FileWriter("./codescript/"+nomFichier));
    out.write("set title \"Variation du type de test au cours du temps\";");
    out.newLine();
    out.write("set key invert reverse Left outside; set key autotitle columnheader;");
    out.newLine();
    out.write("set yrange [0:"+ordonnee+"]; set auto x;");
    out.newLine();
    out.write("unset xtics;");
    out.newLine();
    out.write("set xtics nomirror rotate by -45 scale 0 font \",8\";");
    out.newLine();
    out.write("set style data histogram;");
    out.newLine();
    out.write("set style histogram rowstacked;");
    out.newLine();
    out.write("set style fill solid border -1;");
    out.newLine();
    out.write("set boxwidth 0.75;");
    out.newLine();
    out.write("#;");
    out.newLine();
    out.write("plot './gnuplot/"+nomFichier+"' using 2:xtic(1), for [i=3:22] '' using i; pause -1;");
    out.newLine();

                out.close(); 
            }
            catch (IOException e) 
            { 
                // TODO Auto-generated catch block 
                e.printStackTrace(); 
            }
    
            String[] s = new String[]{"C:\\Program Files (x86)\\gnuplot\\bin\\wgnuplot_pipes.exe",
                    "-e",
                    "load './codescript/"+nomFichier+"'; " 
            };
            try {
                //Process process = Runtime.getRuntime().exec(s);
                Runtime rt = Runtime.getRuntime();
                Process proc = rt.exec(s);
                InputStream stdin = proc.getErrorStream();
                InputStreamReader isr = new InputStreamReader(stdin);
                BufferedReader br = new BufferedReader(isr);
                String line = null;
                while ((line = br.readLine()) != null)
                    System.err.println("gnuplot:"+line);
                int exitVal = proc.waitFor();
                if (exitVal != 0)
                    // log("gnuplot Process exitValue: " + exitVal);
                    proc.getInputStream().close();
                proc.getOutputStream().close();
                proc.getErrorStream().close();
            } catch (Exception e) {
                System.err.println("Fail: " + e);
            }
    
     
  • Bissmark
    Bissmark
    2013-04-25

    I tried to lunch Gnuplot from the terminal, but I still have the problem.
    Here is the script:
    set title "Variation du type de test au cours du temps";
    set key invert reverse Left outside; set key autotitle columnheader;
    set yrange [0:*]; set auto x;
    unset xtics;
    set xtics nomirror rotate by -45 scale 0 font ",8";
    set style data histogram;
    set style histogram rowstacked;
    set style fill solid border -1;
    set boxwidth 0.75;

    ;

    plot './gnuplot/gnuplot_TypeTst_Microsoft Windows XP_Annee.dat' using 2:xtic(1), for [i=3:22] '' using i;

     
  • Ethan Merritt
    Ethan Merritt
    2013-04-26

    The problem is that your data file doesn't really have 22 columns or indeed any fixed number of columns. It has mostly a single column followed by nothing at all, no zero or any other character to indicate missing data. If I add zeros to the end of each line in your sample file then the plot is processed correctly. (attached)

    I.e. change this:
    Date version55_test line_test
    2010-04-30 1
    2010-05-01
    2010-05-02
    2010-05-03
    2010-05-04
    2010-05-05
    2010-05-06 1 1

    to this:
    Date version55_test line_test
    2010-04-30 1 0
    2010-05-01 0 0
    2010-05-02 0 0
    2010-05-03 0 0
    2010-05-04 0 0
    2010-05-05 0 0
    2010-05-06 1 1

    If for some reason 0 is not an option you could instead use a character such as "?"
    and add the command
    set datafile missing "?"

    I agree that your original data file produces unexpected behaviour and the program could probably do a better job of filling in zeros by itself or at least issuing a warning. Let's call that a bug, but it is being triggered by a poorly formatted data file.

     
    Attachments
  • Bissmark
    Bissmark
    2013-05-05

    Great, it works great. I have to say a big "Thanks" for this. Gnuplot is a nice soft, but dealing on the data is not very easy. But in this case obviously the mistake was mine, even it was not easy to find the bug. Thanks again.

    In the mean time, I have another small question. When I have a lot data, in this case "version_test", I do not have have enough color and some data (version_test) appears in the same color which mess up a bit the graph. How is it possible to solve this problem ?

    Gnuplot is part of big project and I d'like to write your name in the report (Thanks part) in regard to your precious help. If you agree you can send me your name at theophile.werle@gmail.com if it's not Ethan Merrit.

    Thanks again,

     
    Last edit: Bissmark 2013-05-05
  • Ethan Merritt
    Ethan Merritt
    2013-05-05

    Each gnuplot terminal comes with some number of pre-defined colors in a sequence. But you are not limited to this set, you can define as many as you like. Some example color definition files are included in 4.7 that you can adapt or use as a model. Here is a dump of the one I use:

     $ cat share/colors_default.gp
     # Ethan A Merritt - my preference for gnuplot colors
     # 2 3 4 5 6 8 are borrowed from the colors_podo set
     #
     set linetype  1 lc rgb "dark-violet" lw 1
     set linetype  2 lc rgb "#009e73" lw 1
     set linetype  3 lc rgb "#56b4e9" lw 1
     set linetype  4 lc rgb "#e69f00" lw 1
     set linetype  5 lc rgb "#f0e442" lw 1
     set linetype  6 lc rgb "#0072b2" lw 1
     set linetype  7 lc rgb "#e51e10" lw 1
     set linetype  8 lc rgb "black"   lw 1
     set linetype  9 lc rgb "gray50"  lw 1
     set linetype cycle  9
    

    Because of that last command the sequence of colors will repeat every 9 plots, but you can define additional linetypes and increase that as you please. And regardless of the number of predefined colors, you can of course include a specific color in each plot command.

    By the way, the issue with handling empty fields in a csv file has now been fixed in the cvs version of the 4.7 code. So if you care, your original data file and plot commands now give the expected result. The work-around is of course still needed when you use previously released versions of gnuplot.