- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
It seems a very easy question but somehow I am struggling with this.
I just want to change the FONT (not font size, this I can do easily) of all text in a plot (in SGPLOT): axis labels and values, legend items...
I guess I have to define a new style, something like:
proc template;
define style my_style;
parent=styles.htmlblue;
class GraphValueText / font = ("<sans-serif>, <MTsans-serif>",20pt);
end;
How can I set the font to Times New Roman, or Arial, etc, instead of sans-serif?
Where can I find a list of available fonts?
And how do I apply the new style to the plot?
Could someone give an example (as easy as possible)?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Below is an example of how to use different fonts. GraphLabelFont controls the axis labels and the legend label. GraphValueFont controls the axis tick values, and the values within the legend. Also, make sure that you actually look at the graph file that is being outputted, i.e. the .PNG file on your C drive.
proc template;
define style styles.new_font;
parent = styles.default;
class GraphFonts
"Fonts used in graph styles" /
'GraphValueFont' = ("Arial",9pt)
'GraphLabelFont' = ("Times New Roman Uni",10pt,
bold);
end;
run;
ods listing style = styles.new_font gpath = "C:\graph";
proc sgplot data=sashelp.class;
scatter x=height y=weight / group=sex;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Below is an example of how to use different fonts. GraphLabelFont controls the axis labels and the legend label. GraphValueFont controls the axis tick values, and the values within the legend. Also, make sure that you actually look at the graph file that is being outputted, i.e. the .PNG file on your C drive.
proc template;
define style styles.new_font;
parent = styles.default;
class GraphFonts
"Fonts used in graph styles" /
'GraphValueFont' = ("Arial",9pt)
'GraphLabelFont' = ("Times New Roman Uni",10pt,
bold);
end;
run;
ods listing style = styles.new_font gpath = "C:\graph";
proc sgplot data=sashelp.class;
scatter x=height y=weight / group=sex;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Also, this link can show you how to find which fonts are available:
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/graphref/n0840ghr9b9y3bn0zphem54hvgbt.htm
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You're welcome. You can add the GraphBackground class to change the fill color from grey to white, as seen below.
proc template;
define style styles.new_font;
parent = styles.default;
class GraphBackground /
color = white;
class GraphFonts
"Fonts used in graph styles" /
'GraphValueFont' = ("Arial",9pt)
'GraphLabelFont' = ("Times New Roman Uni",10pt,
bold);
end;
run;
ods listing style = styles.new_font gpath = "C:\graph";
proc sgplot data=sashelp.class;
scatter x=height y=weight / group=sex;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Another option would be to use the older SAS/Graph proc gplot, where you can control the text font with "goptions ftext=".