我正在為 Haskell 使用 GNUPlot.Simple 并試圖在彼此之上繪制 2 個圖表。一種是使用填充曲線格式,一種是法線。我正在使用的代碼是:
plotListsStyle [] [ (( defaultStyle {plotType = FilledCurves} ) , ( zip3 [1,2,3] [2,3,4] [0,1,2] )), ((PlotStyle {plotType = Lines, lineSpec = CustomStyle [PointSize 0.1] }), (zip [1,2,3] [1,2,3]) )]
當我單獨執行它們時,它們可以正常作業:
plotListsStyle [] [ (( defaultStyle {plotType = FilledCurves} ) , ( zip3 [1,2,3] [2,3,4] [0,1,2] ))]
和
plotListsStyle [] [((PlotStyle {plotType = Lines, lineSpec = CustomStyle [PointSize 0.1] }), (zip [1,2,3] [1,2,3]) )]
但不是一起完成。是否可以將 GNUPlot 相互疊加?
uj5u.com熱心網友回復:
看起來您只需要通過提供一些 GNUPlot 實際上不需要的額外資料來欺騙型別檢查器。嘗試類似:
import Graphics.Gnuplot.Simple
main = do
plotListsStyle []
[ ( defaultStyle {plotType = FilledCurves}
, zip3 [1::Double,2,3] [2::Double,3,4] [0::Double,1,2] )
, ( PlotStyle {plotType = Lines, lineSpec = CustomStyle [PointSize 0.1] }
, zip3 [1::Double,2,3] [1::Double,2,3] (repeat 0))
-- ^^^^^^^^^^
-- Provide this useless extra data
]
這里的問題是plotListsStyle需要一個元組串列,并且 - 與所有 Haskll 串列一樣 - 所有元組都需要屬于同一型別,因此您不能在一個元組中擁有型別資料而在另一個[(Double,Double,Double)]元組中擁有型別資料[(Double,Double)].
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/462867.html
