BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lealange
Calcite | Level 5

I want to display several bar charts with same total width and width/ ratio of the y-axis-labels and x-axis respectively. On the x-axis are metrical values and on the y-axis are the labels. The concrete variables and labels vary from graph to graph. I achieved to fix the total width of each graph to the same value with

ods graphics on / width=18.2cm ;

 

But I do not get the width/ relation of the y-axis-labels and of the x-axis to be equal from graph to graph.

 

I tried it the following, but it does not work as wished.

 

proc template;
    define style styles.mystyle;


    parent=styles.default;

 

    style GraphLabelText from _self_ / width  = 10.2cm   ;

 

    end;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

There is no OPTION to set the width of the Y axis space.  When splitting, the split width used is about 25% of the graph width.  But actual space used depends on the individual cases.  If this is important, you could use a "trick" to do what you want.  Add a Y reference line (transparent) that has a long curve label on the left.  The label should be made up of multiple 'A0'x characters.  This will reserve the space needed for the curve label (which will not be visible).  Then, (hopefully) the tick values will still split within this space.

 

 Also, your graph has a lot of empty space on the -ive x axis space.  I suppose this necessary?

 

 

View solution in original post

6 REPLIES 6
Jay54
Meteorite | Level 14

You can set the overall width and height of the ouput graph but not the length of the axis.  The length of the axis is determined by the software after accounting for titles, axis values, etc.  You can set ASPECT to make the width and height of the data area a certain proportion.  Please include a picture of what you want, and version of SAS you are using.

lealange
Calcite | Level 5

Hi,

 

So you think that it is impossible?

 

The ratio of width and hight ist not the problem but the ratio of axis- and label width. I included a picture to illustrate this better.

problem.png

At the moment b is equal (18cm) in both pictures, but not so a. But I would llike them to both be equal from picture to picture (b shall be fixed to 18 cm's and a to 10 cm's).

 

I tried to fill up the labels with leading blanks to make them equal in length but this did not help because SAS ignores the blanks in the labels.

 

Any further ideas? Thx

Jay54
Meteorite | Level 14

The pictures provide a better understanding of your issue.  You can use YAXIS FITPOLICY=SPLIT or SPLITALWAYS to control splitting of the y axis tick values.  Please see product documentation.  Also see this article.  If you place the two graphs in one GTL LAYOUT LATTICE, then the space for the y axis tick values will be equalized automatically.

lealange
Calcite | Level 5

Thx a lot! The split option for the yaxis does indeed fix the width of "a" from graph to graph as you wrote.

 

But is it maybe also possible to determine the exact width of "a"?

 

Because now the plot is very large as compared to the label area. I would like to fix "a" to 10 cm's if that's possible for better readability.

 

Kind regards

Jay54
Meteorite | Level 14

There is no OPTION to set the width of the Y axis space.  When splitting, the split width used is about 25% of the graph width.  But actual space used depends on the individual cases.  If this is important, you could use a "trick" to do what you want.  Add a Y reference line (transparent) that has a long curve label on the left.  The label should be made up of multiple 'A0'x characters.  This will reserve the space needed for the curve label (which will not be visible).  Then, (hopefully) the tick values will still split within this space.

 

 Also, your graph has a lot of empty space on the -ive x axis space.  I suppose this necessary?

 

 

lealange
Calcite | Level 5

Hi Sanjay,

 

Thank you very much!

 

The "trick" with the transparent reference line on the y-axis which is labeled with a long string made of many blanks works perfect!

In that way the length of the y-axis label space ("a") can be set to any possible value.

The split option is not even needed when the space is wide enough. (actually applying this trick and splitting at the same time is not recommendable because the labels still split after 25 % of total graph width)

 

Kind regards

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
  • 6 replies
  • 2009 views
  • 0 likes
  • 2 in conversation