Data visualization with SAS programming

how to fix the length of the labels and x-axis and the total width of a graph

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

how to fix the length of the labels and x-axis and the total width of a graph

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;


Accepted Solutions
Solution
a month ago
SAS Super FREQ
Posts: 1,110

Re: how to fix the length of the labels and x-axis and the total width of a graph

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


All Replies
SAS Super FREQ
Posts: 1,110

Re: how to fix the length of the labels and x-axis and the total width of a graph

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.

New Contributor
Posts: 4

Re: how to fix the length of the labels and x-axis and the total width of a graph

[ Edited ]

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

SAS Super FREQ
Posts: 1,110

Re: how to fix the length of the labels and x-axis and the total width of a graph

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.

New Contributor
Posts: 4

Re: how to fix the length of the labels and x-axis and the total width of a graph

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

Solution
a month ago
SAS Super FREQ
Posts: 1,110

Re: how to fix the length of the labels and x-axis and the total width of a graph

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?

 

 

New Contributor
Posts: 4

Re: how to fix the length of the labels and x-axis and the total width of a graph

[ Edited ]

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 204 views
  • 0 likes
  • 2 in conversation