BookmarkSubscribeRSS Feed
martyvd
Fluorite | Level 6

The highest and lowest y-axis ticks on my graph are not meeting the axis line properly. See my yaxis code and pictures below. I am using SGPLOT.

yaxis label='Percent of all admissions aged 12 years and older' VALUES = (0 TO 50 BY 10) tickvalueformat=data labelattrs=(family=Arial size=8) offsetmax=0 offsetmin=0 
thresholdmin=1 thresholdmax=1 valueattrs=(family=Arial size=8);

yaxistick.JPGxaxistick.JPG

5 REPLIES 5
ballardw
Super User

It is a good idea to share some data that will recreate the issue and show the entire procedure code.

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

Provide all ODS graphics options that are also in effect when the program is run.

 

Since this is an appearance issue which ODS destination are you sending the output to?

In some cases some resolution of monitor/graphic file type and DPI settings can cause things not to appear to align at some viewing resolutions.

martyvd
Fluorite | Level 6

The output destination is PDF. See my full code below. I've also attached my data. 

proc template;
define style Custom;
parent = Styles.default; 
class graphaxislines/color=black width=0.75pt;
class graphbackground/color=white;
end;
run;

PROC IMPORT OUT= WORK.prim_sub_use DATAFILE= "E:\SAS figures\Primary substance use data"
            DBMS=xlsx REPLACE;
     		GETNAMES=YES;
RUN;

data prim_sub_use;
set prim_sub_use; 
label 
Alcohol	='^_^_Alcohol^_'
Opiates	='^_^_Opiates^_'
Cocaine	='^_^_Cocaine^_'
Marijuana='^_^_Marijuana/hashish^_'
Methamphetamine_amphetamines='^_Methamphetamine/amphetamines^_'
;
run;

ods _all_ close;
options nonumber nodate orientation=landscape papersize=letter nocenter
leftmargin=.5in rightmargin=.5in topmargin=.5in bottommargin=.5in;
ods pdf file="E:/SAS figures/fig1_pdf_new.pdf" dpi=300 notoc;
ods pdf style=Custom;
ods layout start style={bordercolor=white borderstyle=solid borderwidth=1pt backgroundcolor=white} description='Primary substance use at admission, 2007-2017';
ods noptitle;
ods region x=0in y=0in width=6.5in style=[borderwidth=1 bordercolor=white backgroundcolor=white];
ods graphics on/ reset=all border=off noborder width=6.5in scale=on;
title;

proc sgplot data=prim_sub_use noborder nowall;
series x=Year y=Alcohol/markers markerattrs=(symbol=CircleFilled color='#0060A9' size=12) lineattrs=(color='#0060A9' thickness=1.5pt);
series x=Year y=Opiates/markers markerattrs=(symbol=TriangleDownFilled size=12 color='#ed1c24') lineattrs=(color='#ed1c24' thickness=1.5pt pattern=solid);
series x=Year y=Cocaine/markers markerattrs=(symbol=SquareFilled color='#ffc222' size=12) lineattrs=(color='#ffc222' thickness=1.5pt pattern=solid);
series x=Year y=Marijuana/markers markerattrs=(symbol=DiamondFilled color='#64c069' size=12) lineattrs=(color='#64c069' thickness=1.5pt pattern=solid) legendlabel="Marijuana/hashish";
series x=Year y=Methamphetamine_amphetamines/markers markerattrs=(symbol=TriangleFilled size=12 color='#00a2e5') lineattrs=(color='#00a2e5' thickness=1.5pt pattern=solid);
yaxis label='Percent of all admissions aged 12 years and older' VALUES = (0 TO 50 BY 10) tickvalueformat=data labelattrs=(family=Arial size=8) offsetmax=0 offsetmin=0 
thresholdmin=1 thresholdmax=1 valueattrs=(family=Arial size=8);
xaxis label='Admission Year' VALUES = (2007 TO 2017 BY 1) display=(nolabel noticks) valueattrs=(family=Arial size=8);
keylegend/noborder linelength=30 fillaspect=golden valueattrs=(family=Arial size=8);
run;

ods graphics off;
ods layout end;
ods pdf close;
ods _ALL_ CLOSE;
PGStats
Opal | Level 21

It could be that antialiassing has been turned off. This happens when there are more than 4000 elements to draw in a plot. You can ask for a higher limit in the ODS GRAPHICS statement with option

 

ANTIALIASMAX= 100000

PG
martyvd
Fluorite | Level 6
Adding this option does not seem to make any difference.
ghosh
Barite | Level 11

Either suppress the tickmarks or use the accepted solution (inside ticks), both shown here

 

https://communities.sas.com/t5/Graphics-Programming/SGPLOT-how-to-get-tick-marks-inside/td-p/343401

 

If you do keep the status quo, I don't believe anybody will even notice the tick lines not matching at the joint

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 581 views
  • 0 likes
  • 4 in conversation