JavaPlot timestamps not working

232 views Asked by At

I have a file like

1429520881 15.0
1429520882 3.0
1429520883 340.0

and I try to use it in JavaPlot

JavaPlot plot=new JavaPlot();
GenericDataSet dataset=new GenericDataSet();
filling dataset with data
...
plot.set("xdata","time");
plot.set("timefmt","'%s'");
plot.set("format x","'%H:%M:%S'");
plot.plot();

in result gnuplot's window don't appear but If I try this file directly in gnuplot with the same data and options it shows me a time on xAxis; If in JavaPlot I delete last settings(xdata, timefmt,format) it works but it shows me only numbers

I also tried to create manualy dataset with data in program but the same result.

I also implement new DataSet with date as String but it seems that xdata,time option doesn't work

2

There are 2 answers

3
Vadim On BEST ANSWER

It generates temp script file with data inside in weird order because of ParametersHolder inherits HashMap and there should be "using" keyword after '-' for example: I wrote LinkedParams extends GNUPlotParameters class with inner LinkedMap and overrided methods to use inner structure;

set ... ...(xrange,yrange etc)
set xdata time
set timefmt '%s'
set format x '%H:%M:%S'
plot '-' using 1:2 title 'ololo' with linesploints lineType 2 lineWidth 3
1429520881 15.0
1429520882 3.0
1429520883 340.0
e
quit

but it was

set xdata time
set ... ...(xrange,yrange etc)
set format x '%H:%M:%S'
set timefmt '%s'
plot '-' title 'ololo' with linesploints lineType 2 lineWidth 3
1429520881 15.0
1429520882 3.0
1429520883 340.0
e
quit
0
Slaphead On

It took forever to figure this one out. I found that if you have a DataSetPlot object you can set the 'using' option:

DataSetPlot dataSet = new DataSetPlot( values );
dataSet.set( "using", "1:2" );

This will then make use of the 'using' option for the plot command, eg:

plot '-' using 1:2 title 'Success' with lines linetype rgb 'green'

You have to have the 'using' option when making use of time for the x axis, otherwise you will see this error:

Need full using spec for x time data