Here is an example of how to set the legend inside polt, included in JFreeChart Samples XYTitleAnnotationDemo1 , this is the key part
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);

Grahama
source share