-1

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

Vadim
  • 47
  • 7

2 Answers2

1

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

Slaphead
  • 81
  • 1
  • 5
0

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
Vadim
  • 47
  • 7
  • What if internally the properties were stored in an ordered list? Would this solve this problem? – Panayotis Nov 18 '15 at 21:04
  • @Panayotis I believe, that is right. Unfortunately the order of settings for Gnuplot is very important. I also wrote an extended GNUPlotParameters and when `entrySet()`, `put()` and `remove` are overridden to use an internal `LinkedHashMap` the order of commands remains intact. Unfortunately, `PropertiesHolder` inherits from `HashMap`, which is bad design imho. – kap Jan 26 '18 at 09:49
  • That's the reason I ask. If it is changed to LinkedHashMap? The desing was too old to judge :) – Panayotis Jan 28 '18 at 23:53