BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
hellohere
Pyrite | Level 9

Use Proc GPLOT generate the time-series plot below. Somehow the line thickness is too much, any way to slim it?!

I tried the options whref/wvref, somehow get confused. 

 

	proc gplot data=mydata;
	plot (var_y1a var_y1b)*ind/legend overlay WAUTOHREF=0.2;
	plot2 (var_y2)*ind/legend overlay noaxis;
	run;quit;

gplot54.png

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You question has nothing to do with "line thickness" as you not plotting a "line" at all. That is the result of overlapping many + symbols close together.

 

Personally I would suggest moving to Proc SGPLOT as that is where many improvements to plotting in general have been made.

 

For Gplot the SYMBOL settings control the appearance of the plotted items, one symbol statement for each appearance value.

 

In a SYMBOL statement to create a line you would set Interpol=Join (interpol here is "interpolation") to connect points, use the LINE= (1 to 46 ) to set the line type (solid and combinations of dots, short and long dashes and space betwee) and VALUE=NONE to not use markers (which is what is making the 'line' wide). There are additional options for line thickness (WIDTH) and such.

 

Try adding this to the code before the Gplot:

Symbol1 value=none 
        line=1 
        color=red 
        interpol=join
;
Symbol2 value=none 
        line=2 
        color=blue 
        interpol=join
;
Symbol3 value=none 
        line=3 
        color=black 
        interpol=join
;

 

View solution in original post

5 REPLIES 5
ballardw
Super User

You question has nothing to do with "line thickness" as you not plotting a "line" at all. That is the result of overlapping many + symbols close together.

 

Personally I would suggest moving to Proc SGPLOT as that is where many improvements to plotting in general have been made.

 

For Gplot the SYMBOL settings control the appearance of the plotted items, one symbol statement for each appearance value.

 

In a SYMBOL statement to create a line you would set Interpol=Join (interpol here is "interpolation") to connect points, use the LINE= (1 to 46 ) to set the line type (solid and combinations of dots, short and long dashes and space betwee) and VALUE=NONE to not use markers (which is what is making the 'line' wide). There are additional options for line thickness (WIDTH) and such.

 

Try adding this to the code before the Gplot:

Symbol1 value=none 
        line=1 
        color=red 
        interpol=join
;
Symbol2 value=none 
        line=2 
        color=blue 
        interpol=join
;
Symbol3 value=none 
        line=3 
        color=black 
        interpol=join
;

 

hellohere
Pyrite | Level 9

Like to swtich to SGPLOT, could you give out an example with two y-axis with varied range?!

I only know how to plot 2-y-axis with GPLOT so far. 

PaigeMiller
Diamond | Level 26

Examples:

https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-y2axis-and-legend/m-p/230789#M8353

https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-with-2-y-axes/m-p/453755#M15558

 

Agreeing with @ballardw you don't really want a scatter plot, you want a series plot, so use the SERIES command in PROC SGPLOT instead of SCATTER.

--
Paige Miller
ballardw
Super User

@hellohere wrote:

Like to swtich to SGPLOT, could you give out an example with two y-axis with varied range?!

I only know how to plot 2-y-axis with GPLOT so far. 


Not sure what you mean by "varied range" but you use the option  Y2AXIS added to a plot to use the alternate Y axis:

proc sgplot data=sashelp.class;
   scatter x=age y=weight;
   scatter x=age y=height /y2axis;
run;

The option / X2AXIS would use a secondary (top) X axis.

 

The Y2AXIS statement would control appearance such as restricting value range, setting tick marks and labels for the second axis just as the XAXIS and YAXIS statements control the basic X and Y axis appearance.

 

The basic Sgplot would look like:

proc sgplot data=mydata;
	series y=var_y1a x=ind;
	series y=var_y1b x=ind;
	Series y=var_y2 x=ind /y2axis;
run;

From what your original graph looks like I might suspect you might want to consider reshaping the data to one "var_y1" variable with another variable to hold the "A" and "B" difference and use the Group= option.

If you do not want any Y2AXIS displayed (bad idea in my mind as the axis could be considerably different and have implied similarity to the left axis) then this statement would suppress the appearance.

y2axis display=none;

 

hellohere
Pyrite | Level 9
8302      symbol1 width=0.2;
8303      symbol2 width=0.5;
8304      proc gplot data=mydata;
8305      plot (var_y1a var_y1b)*ind/legend overlay;
8306      plot2 (var_y2)*ind/legend overlay noaxis;
8307      run;

Tried the one with symbol1/2, still the line thickness is too much. 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1842 views
  • 0 likes
  • 3 in conversation