2013-02-20 65 views
1

我想出了我最后的滞后情节,它看起来像这样:添加传说的JFreeChart

enter image description here

我先前的职位: Plotting a hysteresis loop with jFreeChart

我已经使用了4个XYSeries我的第一个滞后循环,另外四个用于第二个滞后循环。

如果我打开传说

JFreeChart chart = ChartFactory.createXYLineChart(
"Hysteresis Plot", // chart title 
"Pounds(lb)", // domain axis label 
"Movement(inch)", // range axis label 
dataset, // data 
PlotOrientation.VERTICAL, // orientation 
true, // include legend 
true, // tooltips 
false // urls 
); 

看起来是这样的:

enter image description here

我只是想表明,蓝色是我第一次磁滞回线和红色是我的第二磁滞回线,作为解决方法,我在第一张图片中添加了字幕。有人可以指导我如何添加指示蓝色为第一个循环和红色为第二个的手动图例。

感谢

回答

1

因为ChartFactory.createXYLineChart()创建XYPlot,你可以尝试setFixedLegendItems(),提到herehere

一个更加雄心勃勃的方案是抑制本地图例并在独立组件中渲染图例项目,如here所示。