2015-04-28 65 views
-1

我有一个像JavaPlot时间戳不工作

1429520881 15.0 
1429520882 3.0 
1429520883 340.0 

一个文件,我尝试使用它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(); 

在结果gnuplot的窗口没有出现,但如果我尝试这个文件直接在gnuplot具有相同的数据和选项,它显示了我在xAxis上的时间;如果在JavaPlot中我删除了最后一个设置(xdata,timefmt,格式),但它只显示数字

我还尝试在程序中创建带有数据的手动数据集,但结果相同。

我也实现了与日期字符串新的DataSet,但它似乎外部数据,时间选项不起作用

回答

0

它产生内部进行数据的临时脚本文件,因为ParametersHolder奇怪的顺序继承HashMap和应该有“使用“关键字后' - ' 例如: 我写了LinkedParams扩展GNUPlotParameters类与内部LinkedMap和覆盖方法使用内部结构;

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 

,但它是

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

如果内部属性存储在有序列表中,该怎么办?这会解决这个问题吗? – Panayotis

+0

@Panayotis我相信,那是对的。不幸的是,Gnuplot的设置顺序非常重要。我还写了一个扩展的GNUPlotParameters,并且当'entrySet()','put()'和'remove'被覆盖以使用内部'LinkedHashMap'时,命令的顺序保持不变。不幸的是,'PropertiesHolder'继承自'HashMap',这是糟糕的设计。 – kap

+0

这就是我问的原因。如果它更改为LinkedHashMap?设计太老了,无法判断:) – Panayotis

1

花了永远推测这一个。我发现,如果你有一个DataSetPlot对象,你可以设置“使用”选项:

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

这一操作将利用“使用”选项用于绘图命令,如:

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

您必须在使用x轴的时间时使用“使用”选项,否则您将看到此错误:

Need full using spec for x time data