【问题标题】:Adding legend to jFreechart将图例添加到 jFreechart
【发布时间】:2013-02-20 12:16:26
【问题描述】:

我想出了我的最终滞后图,如下所示:

我之前的帖子: 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
);

它看起来像这样:

我只想表明蓝色是我的第一个磁滞回线,红色是我的第二个磁滞回线,我已在第一张图片中将其作为副标题添加为解决方法。有人可以指导我如何添加手动图例,将蓝色作为第一个循环,将红色作为第二个循环。

谢谢

【问题讨论】:

    标签: java jfreechart


    【解决方案1】:

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

    一个更雄心勃勃的方案是抑制原生图例并将图例项呈现在单独的组件中,如here所示。

    【讨论】:

      猜你喜欢
      • 2011-12-18
      • 1970-01-01
      • 1970-01-01
      • 2012-09-12
      • 1970-01-01
      • 2022-01-23
      • 1970-01-01
      • 2019-08-21
      相关资源
      最近更新 更多