BookmarkSubscribeRSS Feed
PTD_SAS
Obsidian | Level 7

I use gplot (SAS 9.4.3) with unevenly spaced axis values (see attached) as 3 ranges: -2 to +2, 4.24 to 4.36 and 20 to 42. While I can specify different colours for the axis labels, is there a way to apply different colours to axis values as well?

Thanks. 

4 REPLIES 4
Jay54
Meteorite | Level 14

It is not clear what your objective is.  Your Y axis has three distince ranges - "-2.0 to 2.0",  "4.24 to 4.36" and "20 to 42".  These are not drawn with a consistent linear scale.  Are they really one graph?  Why not separate it into three graphs, one each for "MD Taps", "Volts" and "Auxiliary MW".

 

Alternatively, you could use bands in the graph to display the three regions, especially if each region does not end exactly at the value on the axis.  With SGPLOT, you can use the BAND statement.

PTD_SAS
Obsidian | Level 7

Sanjay,

Thanks for your comments. I overlay 5 different graphs with different value ranges on the 2 vertical axises, i.e. 2 graphs on the left axis and 3 graphs on the right axis. I had to split the axis value ranges into non linear groups and was just looking at a way to have the axis value ranges the same colour as the corresponding graphs.

I'll have a look at SGPLOT and BAND as you suggested.

Jay54
Meteorite | Level 14

What ius the benefit of multiple plots with different value ranges on one Y axis?  Could you not gain the same insight if the plots were stacked on a common x-axis?  Can you provide a non-confidential example?

PTD_SAS
Obsidian | Level 7

Hi Sanjay,

Attached is my code and the graph output, haven't been able to attach the dataset, won't accept it.

 

I actually plot 6 variables on a shared x axis and 2 vertical axes. You'll notice the uneven axis ranges in the axis statements for the vertical axes, my aim was to be able to specify different colours for each range so it makes the graph more readable. E.g. in the right vertical axis, to have -2 to 2 in red, 4.24 to 4.36 in purple and the rest in green.


FN graph.gif

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1190 views
  • 1 like
  • 2 in conversation