BookmarkSubscribeRSS Feed
xxformat_com
Barite | Level 11

Hi,

 

When using proc sgplot, are those statements correct?

 

When a legend has position=right:

1/ Legend title: As far as I could see there is not titlealign available in keylegend to left align the legend title; legenditem is only for the values. So the only solution would be using text annotation.

2/ Legend: padding between values is not possible

 

Axis

3/ Axis and tick colors: it is not possible to change it.

4/ It is not possible to define the distance between the axis and the values (e.g y-axis in a vertical bar chart)

5 REPLIES 5
Ksharp
Super User

It would be better if you could post a graphic to illustrate your question.

The following is for your first three questions.

The last question you could try YAXISTABLE statement.

https://blogs.sas.com/content/graphicallyspeaking/2017/10/12/advanced-ods-graphics-two-types-axis-ta...

https://blogs.sas.com/content/graphicallyspeaking/2017/01/11/advanced-ods-graphics-axis-tables-in-pr...

https://blogs.sas.com/content/iml/2019/09/11/axis-tables-rotated-text.html

 

data have;
 set sashelp.heart;
 _s=ifc(status='Dead','xxxxxxxxxxvvvxxxx','yyyyxxxyyyyyyy');
run;


ods html style=sasweb;
proc sgplot data=have ;
scatter x=weight y=height/group=_s ;
keylegend / position=right title='ss                           '; 
run;

Ksharp_0-1718157532083.png

 

xxformat_com
Barite | Level 11

ok. So trailing blanks solve problem 1 when we know in advance how many blanks are needed. Thanks.

 

But you example does not show how to modify the padding above/below each value of the legend item.

 

It also does not show how to change the color of the axis and ticks on the axis.

 

When it comes to yaxistable, I doubt it would solve the problem with a linear axis.

ballardw
Super User

@xxformat_com wrote:

ok. So trailing blanks solve problem 1 when we know in advance how many blanks are needed. Thanks.

 

But you example does not show how to modify the padding above/below each value of the legend item.

 

It also does not show how to change the color of the axis and ticks on the axis.

 

When it comes to yaxistable, I doubt it would solve the problem with a linear axis.


Please do not complain about missing items when you have not 1) provided base Sgplot code to modify, 2) data for that to plot 3) clear description of how much "padding" and exactly where it would go 4) any particular rules on "change the color of the axis and ticks on the axis"

 

Note that if you need more control than SGPLOT XAXIS statement supplies then you can move the Graphic Template Language which has more axis controls such as TICKVALUEATTRS

 

Here is a link to an example that uses an annotate data set to replace tick mark values with text, in different colors, for each value displayed including unicode character as part of the "tick mark".

 

The AXIS line colors are controlled by the Style in effect and is set in the definition of class GraphAxisLines so feel free to modify the axis definition in the style of your base style.

 

Note that the more control over specific elements you want the more you have to do to get there.

xxformat_com
Barite | Level 11

There was no complain on my side. If it has offended someone, I apologize as it was not the intention.

I just assumed that the question was obvious as it was the default setting by all bar charts.

The four points here was just to make sure I didn't miss any option. There are so many options and what some are doing it not clear to me upfront.

It's good to know that GTL offers more flexibilty. I haven't dive into proc template yet.

Ksharp
Super User

"But you example does not show how to modify the padding above/below each value of the legend item."

You could try VALUESATTRS= option.like this:

proc sgplot data=have  ;
scatter x=weight y=height/group=_s ;
keylegend /valueattrs=( size=12   family='courier') position=right title='ss                           '; 
run;

Ksharp_0-1718241555514.png

 

If it was not fit your demand, yes, you should try text annotation.

 

 

"It also does not show how to change the color of the axis and ticks on the axis."

As ballardw pointed out , GTL could do it , text annotation also can do it .

https://communities.sas.com/t5/Graphics-Programming/Pi-Day-Challenge-Draw-Newton-s-diagram-for-appro...

 

"When it comes to yaxistable, I doubt it would solve the problem with a linear axis."

Check this:

https://blogs.sas.com/content/iml/2019/09/11/axis-tables-rotated-text.html

If it is still not fit your requirement, yes , try text annotation.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 403 views
  • 3 likes
  • 3 in conversation