#1087 Combined XY Plot Axis Display Area Problem

General (896)

When I am using CombinedDomainXYPlot with a PeriodAxis, the starting and ending position of the axis seems not correct, with the starting position shifted a little bit to the left-side, and the ending position shifted to the right-side, i.e. the axis is longer than it should be, causing the ticks in between does not match exactly with the grid lines in the sub-plots.

When the same PeriodAxis is added to the sub-plots, this problem does not occur. All the demos under Combined Axis Charts in the JFreeChart 1.0.13 Demo Collection seems have these problem as well.


  • Comment has been marked as spam. 

    You can see all pending comments posted by this user  here

    Anonymous - 2012-05-03

    Screenshot of a problematic chart

  • Comment has been marked as spam. 

    You can see all pending comments posted by this user  here

    Anonymous - 2012-05-15

    Found a temporary workaround for the issue.

    By overriding the draw() method and adjust dataArea before passing it to super.draw():

    dataArea.setRect(dataArea.getX()+4, dataArea.getY(), dataArea.getWidth()-8, dataArea.getHeight());

  • Jean-Yves LINET

    Jean-Yves LINET - 2012-08-04

    A complete fix has to take care of the axisOffset.
    I suggest a fixed code in attached file.

  • Jean-Yves LINET

    Jean-Yves LINET - 2012-08-04

    Well I don't find how to attach a file... so here the method Draw fix :
    public void draw(Graphics2D g2,
    Rectangle2D area,
    Point2D anchor,
    PlotState parentState,
    PlotRenderingInfo info) {

    // set up info collection...
    if (info != null) {

    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();

    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);

        this.getAxisOffset\(\).trim\(dataArea\);    // fix part \#1

    // set the width and height of non-shared axis of all sub-plots

    // draw the shared axis
    ValueAxis axis = getDomainAxis();
    RectangleEdge edge = getDomainAxisEdge();
    double cursor = 0.0 ; //RectangleEdge.coordinate(dataArea, edge);
    // fix part #2
    if (edge == RectangleEdge.TOP) {
    cursor = dataArea.getMinY() - this.getAxisOffset().calculateTopOutset(dataArea.getHeight());
    else if (edge == RectangleEdge.BOTTOM) {
    cursor = dataArea.getMaxY() + this.getAxisOffset().calculateBottomOutset(dataArea.getHeight());
    else if (edge == RectangleEdge.LEFT) {
    cursor = dataArea.getMinX() - this.getAxisOffset().calculateLeftOutset(dataArea.getWidth());
    else if (edge == RectangleEdge.RIGHT) {
    cursor = dataArea.getMaxX() + this.getAxisOffset().calculateRightOutset(dataArea.getWidth());
    // fix end
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
    if (parentState == null) {
    parentState = new PlotState();
    parentState.getSharedAxisStates().put(axis, axisState);

    // draw all the subplots
    for (int i = 0; i < this.subplots.size(); i++) {
    XYPlot plot = (XYPlot) this.subplots.get(i);
    PlotRenderingInfo subplotInfo = null;
    if (info != null) {
    subplotInfo = new PlotRenderingInfo(info.getOwner());
    plot.draw(g2, this.subplotAreas[i], anchor, parentState,

    if (info != null) {


  • rocktyt

    rocktyt - 2013-05-22

    This problem is still remained in 1.0.14, and I tried 2#'s way but no effect.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks