Secondary Axis
Using secondary axis in overlaid graphs can improve its visualization.
- Define principal and secondary graphs.
- Set the option 'useSecondaryAxis' to true into the options of the secondary graph.
- Set the option 'y2AxisColor' to the same color of the secondary graph.
One line using a secondary axis
If the option 'y2AxisColor' is not defined, the secondary y-axis color by default will be black. The option 'y2AxisColor' must be defined into the options of the secondary graph.⎘
x = 0:0.1:2*pi% defining X values
op1 = struct% initializing options struct, principal graph options
op1.show = false op1.lineStroke = 'purple' s1 = plot(x,cos(x),op1)% principal graph
op2 = op1% initializing options struct, secondary graph options
op2.lineStroke = 'orange' op2.useSecondaryAxis = true% secondary axis
op2.y2AxisColor = 'orange'% same color as the line to which it refers
s2 = plot(x,sin(x)*1000,op2)% secondary graph
overlay({s1,s2})
More than one lines using a secondary axis
If the option 'y2AxisColor' is not defined, the secondary y-axis will be black. The option 'y2AxisColor' must be defined into the options of the first graph with secondary options. To have the same color for all the lines refering to the secondaty y-axis it's necesary to set their color manually for each line.⎘
x = 1: 0.2: 10% defining X alues
o1 = struct% initializing options struct
o1.show = false c1 = area(x, cos(x), o1)% principal graph
o2 = o1% initializing options struct
o2.useSecondaryAxis = true% first line with secondary axis
o2.lineStroke = 'red' o2.y2AxisColor = 'red'% same color as the line to which it refers
c2 = plot(x, sin(x), o2)% secondary graph
o3 = o1% initializing options struct
o3.useSecondaryAxis = true% second line with secondary axis
o3.markerStroke = 'red' o3.useSecondaryAxis = true c3 = scatter(x, 2*cos(x+2), o3)% secondary graph
overlay({c1,c2,c3})