2015-04-28 89 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