Often when the data includes some extreme difference in measures or some outliers, the plot of the data points can get skewed due to the need to accommodate the extreme outliers. The bulk of the observations get squeezed into a smaller region of the plot. While this may be useful in some cases, often we want to allow the data to fill the plot region while still drawing the outliers.
In such cases, a broken axis allows us to do just this. The previous article described how to use the Broken Axis feature first released with SAS 9.40M1.
On the right is a contrived example of a case where the response value for one of the categories (E) is very large as compared to the other values. The large value causes the other values for categories "A", "B", "C" and "D" to be scaled down to where it is hard to make a good comparisons between these values.
The graph on the right uses the Broken Axis feature first released with SAS 9.4M1, using the code shown below. The RANGES option on the YAXIS statement allows us to specify the data ranges we want to keep in the graph.
proc sgplot data=tallbar;
vbar x / response=y nostatlabel;
yaxis ranges=(min-44 384-max) values=(0 to 400 by 10);
In this case, we have requested to keep the ranges from minimum to 44 and from 384 to maximum. Note, the value "44" is selected to place the break between the ticks. Also, the axis VALUES need to be provided to give the best results. The same tick interval is preserved in all the axis ranges. There can be more than one break, but on only one axis at a time.
With SAS 9.40M1, the break was represented in the graph as the "Full Break" shown in the graph above. This was useful when breaking plot elements like bars or needles that have a continuous nature, and span over large parts of the graph width or height. However, this type of break was considered too distracting, and not preferred when breaking an axis for a scatter plot.
Based on such feedback from users, SAS 9.40M3 release includes the ability for us to request a lighter weight "Axis Break" as shown in the graph on the right. The code is shown below. Note the use of the AXISBREAK option inthe STYLEATTRS statement. Here we have selected "Bracket", which breaks only the axis using the two short bars. Click on the graph for a higher resolution view.
proc sgplot data=outOfRange;
reg x=x y=y / clm markerattrs=(size=5);
yaxis ranges=(min-1.5 8.9-max) values=(0 to 10 by 0.2) valueshint;
Note another interesting feature in the graph on the right. The X and Y axis lines does not extend all the way to touch each other. This provides another "look and feel" for the graph display, often preferred by some users. This is controlled by the AXISEXTENT option on the STYLEATTRS statement as shown below. Note, the axis line extends to the data range only. So, in this case, the data range goes beyond the extreme tick marks on the y-axis.
styleattrs axisbreak=spark axisextent=data ;
Full SAS9.40M3 Code: BrokenAxis