SVGGraph dual and multiple Y-axis graphs

« Return to SVGGraph page

Skip to:

Sometimes one Y-axis just isn't enough. Starting in version 2.15, SVGGraph supports drawing a second axis on the right hand side of several of the graph types to show a different scale.

SVGGraph 2.27 adds support for drawing multiple Y-axes using the same option.

Enabling the second axis

Figure 1 below demonstrates what happens when you try to plot two different series of values on one grouped bar graph when the values in one series are orders of magnitude greater than the other. There are green bars in between the orange bars, but their height is less than a pixel so they cannot be seen.

BobEveSueJoePamTim02,0004,0006,0008,00010,00012,00014,00016,00018,00020,000
1. Default settings
BobEveSueJoePamTim02,0004,0006,0008,00010,00012,00014,00016,00018,00020,000051015202530354045
2. Dual axis enabled
dataset_axis = [0, 1]

Figure 2 above shows the effect of setting the dataset_axis option to an array containing the values 0 and 1. The values in the array set the axis for each dataset in turn, 0 being the left axis and 1 the right - so the first dataset will be shown on the left, the second on the right.

It is not very clear from figure 2 which axis goes with which group of values, so to make it easier to indicate which is which, SVGGraph supports supplying an array to the axis styling options with an entry for each of the individual axes. Figure 3 shows the same graph with the Y axes and text labels coloured to match the bars.

BobEveSueJoePamTim02,0004,0006,0008,00010,00012,00014,00016,00018,00020,000051015202530354045
3. Restyled axes
axis_text_colour_v = ["#930", "#390"]
axis_colour_v = ["#930", "#390"]
BobEveSueJoePamTim02,0004,0006,0008,00010,00012,00014,00016,00018,00020,000Sales051015202530354045Ages
4. Labelled axes
label_v = ["Sales", "Ages"]
label_colour_v = ["#930", "#390"]

Figure 4 above shows a multi-line graph instead of the grouped bar graph, with added axis labels.

The dataset_axis option is supported by all the vertical multi-dataset graphs apart from the stacked types. The stacked bar and line graph supports dataset_axis for line datasets, but not for the stacked bars.

Multiple Y-axes

Sometimes two Y-axes are not enough - so from version 2.27 of SVGGraph you can actually have as many axes as will fit on the graph:

BobEveSueJoePamTim$0$2,000$4,000$6,000$8,000$10,000$12,000$14,000$16,000$18,000$20,000Sales051015202530354045Age0cm20cm40cm60cm80cm100cm120cm140cm160cm180cm200cmHeight0kg10kg20kg30kg40kg50kg60kg70kg80kg90kgWeight
5. Multiple axes
dataset_axis = [0, 1, 2, 3]
axis_space = 10
units_before_y = ["$", null, null, null]
units_y = [null, null, "cm", "kg"]

Multiple Y-axes uses the same dataset_axis option for specifying the axis to use, but instead of just 0 and 1 you can use any number of axes. The axes on the right of the graph start at 1, then continue with axis 2, axis 3 and so on. The axis numbers must be consecutive or SVGGraph will end up with an empty axis (which it won't be able to draw and you'll get the “Zero-length axis” error).

There is one extra option available when multiple axes are used, “axis_space”. This is the amount of space added between each axis on the right side of the graph (and is added on top of the other axis spacing options).

Multi-axis options

Listed below are all the options that are tagged multi-axis in the options index. These are all the options that have some relevance to multiple axes - the links will take you to the description page for each option.

Note: axis_right is in the list above, but the option does nothing when multiple axes are enabled.

« Back to top of page Date and time options »

This site uses cookies - details here.