【问题标题】:Embed the legend into the plot area of JFreeChart将图例嵌入到 JFreeChart 的绘图区域中
【发布时间】:2012-07-03 22:58:11
【问题描述】:

在JFreeChart 中,是否可以将图例嵌入图表本身? 图例可以设置在图表的上、下、左、右,如下图,但是可以嵌入到图表中吗?

LegendTitle legend=chart.getLegend();
legend.setPosition(RectangleEdge.TOP);

【问题讨论】:

    标签: jfreechart


    【解决方案1】:

    在JFreeChart SamplesXYTitleAnnotationDemo1中包含了如何设置polt里面的图例的例子,这是关键部分:

    XYPlot plot = (XYPlot) chart.getPlot();
    LegendTitle lt = new LegendTitle(plot);
    lt.setItemFont(new Font("Dialog", Font.PLAIN, 9));
    lt.setBackgroundPaint(new Color(200, 200, 255, 100));
    lt.setFrame(new BlockBorder(Color.white));
    lt.setPosition(RectangleEdge.BOTTOM);
    XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.02, lt,RectangleAnchor.BOTTOM_RIGHT);
    
    ta.setMaxWidth(0.48);
    plot.addAnnotation(ta);
    

    【讨论】:

    • 这对 BoxAndWhisker 图有什么作用?我不知道 CategoryPlot 使用哪个注释以及如何使用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-31
    • 1970-01-01
    • 1970-01-01
    • 2015-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多