I have written an enhancement for XYPlot that draws a subtitle in a rectangle directly over the plot. Here an example of two such plots that have been added to a CombinedDomainXYPlot.

Right now I have this in a subclass of XYPlot but conceivably it could be added to the Plot base class so that others could use it as well. Its very handle for both combined xy and combined category plots to label each individual subplot.
Here is the code:
Code: Select all
double width = rectangle2D.getWidth();
double titleHeight = title.getPreferredHeight(graphics2D, (float) width);
double plotHeight = rectangle2D.getHeight() - titleHeight;
Rectangle2D plotRect = new Rectangle2D.Double(
rectangle2D.getX(),
rectangle2D.getY() + titleHeight,
rectangle2D.getWidth(),
plotHeight);
super.draw(graphics2D, plotRect, point2D, plotState, plotRenderingInfo);
Rectangle2D dataArea = plotRenderingInfo.getDataArea();
Rectangle2D titleRect = new Rectangle2D.Double(
dataArea.getX(),
dataArea.getY() - titleHeight,
dataArea.getWidth(),
titleHeight);
title.draw(graphics2D, titleRect);
graphics2D.setStroke(super.getOutlineStroke());
graphics2D.setPaint(super.getOutlinePaint());
graphics2D.draw(titleRect);
Tim