gnuplot converting time to scientific notation - gnuplot

I have this program that grabs a lot of usage details regarding your computer and plots everything on a nice graph (below). The issue I am running into is that in the bottom left corner of the gnuplot window where it would normally report where on the (x,y) axis your mouse is currently at, it is reporting my x-axis in scientific notation.
For example, instead of stating that my mouse is at (33:10,20%) it is reporting that it is as (5.10770e+08,20%) <--Random scientific notation). I have already set the timefmt and xdata, so I am confused at to what I am missing in order to properly report the data. If someone could please help it would be greatly appreciated.
I have searched on superuser and Unix/Linux, and this question seems to fit on Stackoverflow the best as gnuplot has its own scripting language. Also if you look at the gnuplot tag on the various sites, gnuplot fits more on stackoverflow and has thousands of more tags compared to 30 and 67.
I have also viewed Turn Off Scientific Notation In Gnuplot and tried to implement the answer here (Christoph is the GNUPLOT man!), but have thus far been unable to configure it to work properly (it still displays the scientific notation).
gnuplot -e persist "set title 'Resource monitor' ; set timefmt '%y/%m/%d-%H:%M:%S' ; set xdata time ; set xlabel 'TIME' ; set ylabel 'PERCENT' set yrange [0:101]" -e "plot '${cpuResFile}' using 1:2 title 'CPU' smooth Bezier, '${memResFile}' using 1:2 title 'MEM' smooth Bezier ; pause -1"

You're in the right place to ask for gnuplot help!
I've tried this on x11 and wxt, don't know other interactive terminals.
You can switch between different mouse statusbar formats by pressing 1 (2 cycle backwards)
Fore more help on interactivity, press h and you'll get a list ho keyboard shortcuts
Some information is on help mouse format
To change it programmatically with the corresponding command set mouse format (but I didn't manage to display properly date/time...)

Related

Reverse abscissa/ordinate axis in wxdraw2d or wxplot2d wxmaxima

By default, the draw/plot function plots y-axis values in ascending order (from bottom to top). In other words, -ve values are at the bottom of the graph and +ve values above the origin (towards the top of the plot). Can we reverse (see the figure attached) this behavior for the individual axis or both?
It is possible in gnuplot, by passing set xrange reverse and set yrange reverse, but wxmaxima does not provide a full interface for gnuplot, however, it seems that direct access may be possible. As from the docs:
2.3.5 Opening gnuplot’s command console in plot windows
On MS Windows, if in Maxima’s variable gnuplot_command “gnuplot” is replaced by “wgnuplot”, gnuplot offers the possibility to open a console window, where gnuplot commands can be entered into. Unfortunately, enabling this feature causes gnuplot to “steal” the keyboard focus for a short time every time a plot is prepared.
Please also note that there is a difference in gnuplot 4 and 5:
The reverse keyword of the set [axis]range command aects only autoscaling. It does not invert or
otherwise alter the meaning of a command such as set xrange [0:1]. If you want to reverse the direction
of the x axis in such a case, say instead set xrange [1:0].

GNUPLOT cannot zoom in

I am having an issue where I am unable to zoom in on my GNUPLOT. I created a bash script that records various resource information, and displays this information via the following command.
gnuplot -e persist "set title 'Resource monitor' ; set timefmt '%y/%m/%d-%H:%M:%S' ; set xdata time ; set xlabel 'TIME' ; set ylabel 'PERCENT' set yrange [0:101]" -e "plot '${cpuResFile}' using 1:2 title 'CPU' smooth Bezier, '${memResFile}' using 1:2 title 'MEM' smooth Bezier" &
The graph is viewable and displays my information I want, I just cannot figure out how to allow it to zoom in and out. I read that it has something to do with the X11 window no longer being set or that I need to set it via the command line, I just cannot figure out exactly how to, or if this is even the reason. Hopefully there are a couple GNUPLOT experts that can assist me. :)
Thank you.
Zooming and unzooming isn't possible in interactive windows which are left open with the -persist flag. Those operations would require a redrawing which isn't possible anymore since the main programs has already exited.
Quoting from the persist documentation:
[...] gnuplot will open a display window, draw the plot into it, and then exit, leaving the display window containing
the plot on the screen. Depending on the terminal type, some mousing operations may still be possible in
the persistent window. However operations like zoom/unzoom that require redrawing the plot are generally
not possible because the main program has already exited
You could add pause -1 at the end of the command list:
gnuplot -e "plot sin(x); pause -1" &

gnuplot graph with time fmt not working

I have created a script that logs various system resources, and will graph all data points into gnuplot with a nice smooth line. I am running into issues with gnuplot using my time format and plotting the data correctly. A sample of my data file is below
My time format = %H%M%S
"etc. etc." = hundreds of additional recorded times.
170554 3.0%
170556 2.7%
170558 2.6%
etc.
etc.
010218 2.1%
010218 2.3%
If the time of all data plots does not go over the 000000 mark, gnuplot graphs everything correctly. Once my data plots go over that 000000 boundary, gnuplot counts backwards in my time format, so it tries to plot everything that has not been recorded from 170554 - 010218 (numbers not recorded).
Example. 170552 160424 150720 120818.
My gnuplot command I am using is below.
gnuplot -persist -e "set title 'Resource Monitor'; set timefmt '%H%M%S'; set xdata time; set xlabel 'TIME'; set ylabel 'PERCENT'; set yrange [0:101]' set xrange ['170554':'010218']" -e "plot 'log_file' using 1:2 title 'CPU' smooth Bezier"
So my question is...
Why is gnuplot not plotting my graph correctly (the way I want it to via time) and how can I fix this issue? Thank you.
From the documentation
If <ub> is lower than <lb> the constraints will be turned off and full
autoscaling will happen.
To fix it, you will need to supplement your time data with additional "day" information, or find some other way to ensure that later times are never "lower than" earlier times.

gnuplot wxt not working anymore

I have recently upgraded to Debian jessie, meaning that I have upgraded from gnuplot 4.6.0 to gnuplot 4.6.6 (issue is the same with gnuplot 5.0).
I have bash scripts automating things, and launching gnuplot terminal.
I was using either:
gnuplot -persist -e "set title 'Sine curve'; plot sin(x)"
or
gnuplot -persist <<EOF
set title 'Sine curve'
plot sin(x)
EOF
The terminal wxt is no more distributed by debian (and derivatives like ubuntu), because of #751441.
I am using now terminal qt. It displays the plot, but that's the end. The window is static and most of the buttons do not work. I cannot zoom, I cannot unzoom, I cannot show the grid.
How to circumvent this?
Answering my own question: I spent two much time googling, trying to understand why, reading excuses to not correct it, and finding workarounds.
First, you have to remove -persist because it has a wxt special way of working, and it is not the same way of working with qt terminal. See #1418.
Second, you have to add "pause mouse close" after your plot. See #1418. The script is now:
gnuplot -e "set title 'Sine curve'; plot sin(x); pause mouse close"
Now the zoom in, zoom out, and show grid are working.
Third, wait, you did not plotted a sinus, but with lines. Like this example:
$ gnuplot <<EOF
plot '-' using 1:2 t '' with line
0 0
10 10
e
pause mouse close
EOF
Now, if you zoom somewhere in the middle of a segment, you get nothing, an empty and blank screen. What you need is set clip two that tells to not clip when segments ends are not shown. See #1419. So the following will work:
$ gnuplot <<EOF
set clip two
plot '-' using 1:2 t '' with line
0 0
10 10
e
pause mouse close
EOF
Finally, what I have done, is:
add pause mouse close at the end of the script
add set clip two in ~/.gnuplot file
With this, I can mimic the wxt way of working while using qt terminal. IMHO, as a basic end-user, this should be the default.

Why doesn't the gnuplot grid extend over this whole plot?

Using gnuplot 4.6 patchlevel 1, with the following commands,
set grid linewidth 1 linecolor rgb"#888888"
set datafile separator ","
plot for [n=2:100] "data.csv" using 1:(column(n)) with lines linewidth 2
and the following example data in the file "data.csv",
time,S1,S2
0,0.00015,0
0.1,0.0001357256127053939,1.427438729460607e-005
0.2,0.0001228096129616973,2.719038703830272e-005
0.3,0.0001111227331022577,3.887726689774233e-005
0.4,0.0001005480069053459,4.945199309465411e-005
0.5,9.097959895689501e-005,5.902040104310499e-005
0.6,8.232174541410396e-005,6.767825458589604e-005
0.7,7.448779556871142e-005,7.551220443128858e-005
0.8,6.739934461758323e-005,8.260065538241677e-005
0.9,6.098544896108986e-005,8.901455103891014e-005
1,5.518191617571635e-005,9.481808382428365e-005
the resulting plot looks this:
Question: why does the grid only extend partway from the bottom, and not cover the whole plot? I tried a considerable amount of experimentation with the set xtics and ytics commands, arguments to grid, and more, and have not been able to get the grid to cover the whole plot. What am I missing?
Great question! In fact, the answer is that the grid does cover the whole plot. The problem is that the key is taking over. Try it again, but with an unset key in there before your plot command.
What's happening is that gnuplot is reserving space in the key for all of the columns which have no data. Nothing gets put in the space that was reserved since no reasonable data was found. Ultimately, this pushes the 2 lines that were visible out of the viewable canvas area as well.
I've reproduced this using the x11, png, postscript and pngcairo terminals.
Note that this behavior seems to be version dependent:
With gnuplot 4.4.2 (OS-X, png terminal)
With gnuplot 4.6.0 (OS-X, png terminal)
For those using gnuplot 4.4.4, perhaps there was a bug fix which made it work for gnuplot 4.4.4 and then a regression. It seems to persist into gnuplot 4.7.0 as well. I might file a bug report.

Resources