I have a box and whisker plot whereby I want the boxes to be solid but the lines joined at the median to differentiate between the treatment to be different line types.
When I ran this in 9.3 the legend gave me the correct colours and the correct line types. However when I run this in 9.4 I get solid lines (presumably because Ive set the boxes to be solid).
Ok I thought, I'll calculate these and do a series plot and use that for the legend. The issue I have is that the boxes are jittered slightly around the bottom axis and the series plot joins at the specific point.
Ive replicated the code using SASHELP.cars and attached both the 9.3 and 9.4 outputs.
To make the SERIES join in the correct place with the grouped boxes, use GROUPDISPLAY=CLUSTER in the SERIES statement.
When you use unfilled box, the line patterns of the box are included in the legend. Since you set those to PATTERN=1, all the lines in the legend are solid. But, the connect line uses CONNECTATTRS, which is not set. So, you get the patterned lines in the graph. To get solid lines for connect, use CONNECTATTRS=(pattern=1) in VBOX.
Hi Sanjay
Thanks for the quick reply. I don't want solid lines connecting the medians, I want the legend to show patterned lines to match the connecting lines rather than solid. this is what you got with 9.3 but don't get with 9.4.
that's why I added the series plot to connect them and hence use as the legend. However, they don't join in the correct place.
Thanks
Adie.
To make the SERIES join in the correct place with the grouped boxes, use GROUPDISPLAY=CLUSTER in the SERIES statement.
perfect....thank you! I knew there must be a simple solution.
however....is there a simple way to get the legend to match the connected lines without adding the series plot?
I'd tried the type=linepattern on the discretelegend but that gave the solid lines again?
For Box Plot, if the boxes are filled, the legend will display the fill color. If using NOFILL, then the legend will display the lines of the box outlines. You can set the TYPE option on the Legend to display fill, line or markers. Connect line is never displayed in the legend since is not used very often.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.