It is perfectly legal to add several different plot types to the same graph. It is therefore possible to mix line plots with (for example) filled bar graphs. What you should keep in mind doing this is the order in which these plots are stroked to the image since a later stroke will overwrite a previous one. All plots are stroked in the order you add them, i.e. the first plot added will be stroked first. You can therefore control which plot is placed in the background and which one is placed in the foreground by the order you add them to the plot.

To start simple we just mix a filled line plot with a non-filled line plot as the following example shows.

Let's now go to something a little bit more complicated. How to mix bar and line graphs. Let's just take one of our previous bar graphs and add a line plot to it and see what happens.

Not too bad. But we can't see the line so we change the order in which we add the lines to the graph and sees what happens.

If you want the line points to be aligned in the center of the bars you can accomplish this is two ways.

If you use a text scale then you need to call the LinePlot::SetBarCenter()

You can also use an integer scale. This places** both**
the bar and the line points centered at the tick marks. As the
following example will show

As a final example we show how you can combine a scatter plot and a line plot which could be used to illustrate a regression line fitting.

Contents Previous Next