将图例添加到jFreechart

时间:2013-02-20 12:16:27

标签: java 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 个答案:

答案 0 :(得分:1)

由于ChartFactory.createXYLineChart()创建了XYPlot,您可以尝试setFixedLegendItems(),提及herehere

更雄心勃勃的方案是取消原生图例并将图例项目渲染到单独的组件中,如here所示。

相关问题