Search code examples
javajfreechart

Set the size of plots in a CombinedDomain JFreeChart


I created a CombinedDomain/TimeSeries chart, but the plots don't have the same size. The ones on the top of the Panel are smaller than the one below, as the screenshot shows:

Screenshot of how the chart looks

Is there any way to set the size of the plots? I want all the plots to be equal in size, no matter if there's 2 plots or 200.


Solution

  • As shown here, subplots added to a CombinedDomainXYPlot are given equal weight. As shown here, you can specify the desired weight when you add() a subplot.

    The weight determines how much space is allocated to the subplot relative to all the other subplots.

    To get equal size, either use the default:

    plot.add(subplotTop);
    plot.add(subplotBottom);
    

    or specify equal sizes:

    plot.add(subplotTop, 1);
    plot.add(subplotBottom, 1);
    

    enter image description here