BookmarkSubscribeRSS Feed
Andyshen
Calcite | Level 5
Hi everyone, I have two questions to ask:
1.How do we generally control the font size? In some of the charts if I compress the size, the font will become very small, not easy to look at. If I would like to change the font size in all the titles, and labels, what is the correct commend to do that?
2.For x axis and y axis, how to change the position of labels? Say if I want the y axis label to display vertically, which is the command to do that? What if I want to change the label of it, say 'revenue' to 'revenue of department', can I do it simply in the graph instead of in the datasets?
5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Hi:
The answer to your question depends a lot on the code you're using -- all the code. For example, are you using ODS HTML, ODS RTF, ODS PDF? Are you using the device-based "G" procedures -- like GPLOT, GCHART? Are you putting multiple images together with GREPLAY? If you are using the device-based procedures, what are your active GOPTIONS in effect?

On the other hand, you could be using ODS GRAPHICS and the new "SG" procedures (SGPLOT, SGPANEL, etc) or you could be using the GTL (Graph Template Language). These are the template-based methods of creating graphic output. These program options are not controlled by device GOPTIONS, but instead are controlled by ODS GRAPHICS options.

So, you need to provide more information -- and most of the information -- instead of playing 20 questions -- can be provided by showing all of your code (including the ODS "sandwich" statements, so we can understand your destination of interest).

Before you post code to the forum area, you might want to read this previous forum posting that talks about how to protect > and < symbols, preserve code and output indention. This post talks about the LT and GT symbols and also discusses how to emphasize code and how to surround code snippets with [pre] and [/pre]
http://support.sas.com/forums/thread.jspa?messageID=27609毙

cynthia
ChrisNZ
Tourmaline | Level 20
Also, the font size is not respected by all devices. See:
[pre]
ods html;
title h=12pt f='Arial/bo' 'This title will change size';
goption dev=gif ;
proc gchart data=sashelp.class; vbar AGE; run;
goption dev=actximg;
proc gchart data=sashelp.class; vbar AGE; run;
quit;
ods html close;
ArtC
Rhodochrosite | Level 12
Take a look at this paper as well - it addresses a related issue.
http://www.caloxy.com/papers/50-TT05.pdf
deleted_user
Not applicable
1. The best way to control font size for consistency (or at least for my definition of consistency) of your font size, as you change the driver, or version of SAS/GRAPH, or ODS destination, or choice of chart, or whatever, is to use PCT (percent of vertical space available) as the units.

You can, of course, control the size of different parts of the graph directly, with the HEIGHT= (abbrev. H=) parameter, which is now available almost everywhere, or maybe even actually everywhere. And there will be exceptions where you absolutely need direct control. For those, use HEIGHT= where you need it.

However, you can set defaults with
GOPTIONS HTITLE=YourChoice PCT; (where YourChoice need not be an integer)
and
GOPTIONS HTEXT=YourOtherOrSameChoice PCT;

HTITLE controls the height ONLY of TITLE1, and the height of TITLE2, etc. is controlled by HTEXT.

Unless your footnote(s) contains only some boilerplate, you MIGHT want to make your footnote the same height as your title. Footnotes can be a place to put an important message, even if it is at the bottom, rather than the top of the image.

Rather than let SAS/GRAPH choose your defaults (which MIGHT change from version to version of the software), it is best to assert your preferences/standard with HTITLE and HTEXT.

When you say "if I compress the size, the font will become very small", do you mean "compress the displayed size of the image" in some other tool, e.g., Word or PowerPoint? If so, all of its components become smaller. If that's the concern about text size, you need to make your initial choice of text HEIGHT in SAS/GRAPH large enough to be readable in your final result. Sorry if I'm stating the obvious.

2. First, let me admit to a hang-up about rotated text.

We read left to right. Rotated text is always at least marginally less readable. Some examples of rotated text for x-axis tick mark values are a real nuisance, esp. when they are long strings and numerous.

The best place to put the labels for both the y-axis and the x-axis is in the title or the subtitle.

Often, if not almost always, the identity of the axis variables is ALREADY in the title or subtitle, either explicitly or implicitly. And labelling an x-axis of dates as "Date" is inherently superfluous.

The area used to display your graph proper is precious, and best not wasted on axis labels. And don't waste the time and attention of your viewer.

To suppress the label for an axis, use LABEL=NONE on its AXISn statement. You will need to point to the axis statement with HAXIS=AXISn, VAXIS=AXISn, MAXIS=AXISn, or RAXIS=AXISn, as appropriate to your graph. n is some integer, and both axes MIGHT use the same statement.

Too bad that one needs to do extra work and use extra code to suppress superfluous text.

TIP: If you want to minimize typing and code, but want all of your title lines to have the same font, same height, same color, use

TITLE1
FONT='YourTrueTypeFontChoice'
HEIGHT=YourHeightChoice PCT
COLOR=BLACK (unless using a non-light background color for decoration, rather than a visual communication function, black is ALWAYS the most readable color, and is the SAS/GRAPH default)
"title line 1 text"
JUSTIFY=CENTER
"title line 2 text"
JUSTIFY=CENTER
"title line 3 text";

JUSTIFY values can be LEFT, CENTER, or RIGHT. CENTER is the default for TITLE statements. That's why I did not code it before "title line 1 text". Be aware that if you use mixed choices for JUSTIFY in the same TITLEn statement, you will get text strings at different locations on the same line, until you repeat a previously used JUSTIFY value.

You also can use the JUSTIFY= trick to create line breaks in other text strings on your graph.

SideBar about graph titles:

Whenever appropriate, make your graph's top title line a headline.

I.e., tell the viewer the key inference from your data that is demonstrated by your graph. This is certainly feasible in an ad hoc, presentation graph. For production graphs, produced automatically with no opportunity to manual review and edit, such customization is usually impossible.

The usual variable label Information about Y versus X, Y by X, etc. can be put in your second title line.

LeRoy
Bill
Quartz | Level 8
Good lesson LeRoy on some basic data visualization practices
thank you

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