Data visualization with SAS programming

Differentiate line thickness/marker size in sg template w/ graphdata elements

Reply
Frequent Contributor
Frequent Contributor
Posts: 132

Differentiate line thickness/marker size in sg template w/ graphdata elements

Hello all;

IS there a way to only set the graph elements for the first graph data element

So for example;

I have

style Graphdata1 /Color=black line ;

style Graphdata1 /contrastColor=black linethickness=3 ; 

I want only one facility to stand out in terms of having a black line that is thicker and larger markers than the rest of them.  

Many Thanks.

Lawrence

Grand Advisor
Posts: 16,411

Re: Differentiate line thickness/marker size in sg template w/ graphdata elements

Yes, but how depends on what version of SAS you are on.

So, which version are you on?

Frequent Contributor
Frequent Contributor
Posts: 132

Re: Differentiate line thickness/marker size in sg template w/ graphdata elements

Reeza;

Good point-SAS 9.2. I am using indexes. The first index, coordinates graph data element 1. The rest I don't care about per se in terms of color.

Lawrence

SAS Super FREQ
Posts: 1,044

Re: Differentiate line thickness/marker size in sg template w/ graphdata elements

You can set line thickness or marker size in the GraphData elements, but these will not be honored in group case.  The color and pattern come from the GraphData elemtn, but thickness comes from the GraphDataDefault element.  The reason was to provide equal weight to all group values.  To draw one series with a different thickness, you will have to separate it out from the others and draw it with thicker line thickness in the LINEATTRS option.

This works the same way in Attribute Map too.  There have been requests for this feature so this may be added at a future release.

Frequent Contributor
Frequent Contributor
Posts: 132

Re: Differentiate line thickness/marker size in sg template w/ graphdata elements

Thanks Sanjay.

Anyway some conditional logic might work?

Also, is there a way to stop the colors from repeating in a pattern? What I see is that it goes for about 12 different colors, then the whole series repeats itself-

So it might be red, black, green...then back again.

Thanks

Lawrence

SAS Super FREQ
Posts: 1,044

Re: Differentiate line thickness/marker size in sg template w/ graphdata elements

With SAS 9.2, colors and patterns (or symbols) cycle through the lists for each group.  So, first group value gets first color and first pattern, second group gets second color and second patter, and so on till you run out of the 11 patterns.  Then, group #12 gets 12th color and 1st pattern, and it continues..

If you want more colors, define more GraphData elements beyond 12 without any gaps in the color value.  If instead you want to hold the color constant, that is easy, just specify the color in the LINEATTRS option.

Frequent Contributor
Frequent Contributor
Posts: 132

Re: Differentiate line thickness/marker size in sg template w/ graphdata elements

Sanjay;

Thanks.

I tried defining the color after #12, but it seems to not take effect anymore-Are there limits on the number of graphing elements I can choose?

Lawrence

SAS Super FREQ
Posts: 1,044

Re: Differentiate line thickness/marker size in sg template w/ graphdata elements

Here is a SAS 9.2 example.  Note Green and Black color needles and scatter markers for last two names.

Note: ContrastColor is used for the markers, Color is used for bars.

proc template;                                                               
   define style Styles.Thirteen;                                             
      parent = styles.listing;
      style GraphData13 /                                     
         markersymbol="circlefilled"
         linestyle=1
         color=red contrastcolor=green;
      style GraphData14 /                                     
         markersymbol="circlefilled"
         linestyle=1
         color=gray contrastcolor=black;
   end;
run;


ods listing style=thirteen;
ods graphics / reset width=6in height=3in imagename='Thirteen';
proc sgplot data=sashelp.class(obs=14);
  needle x=name y=height / group=name lineattrs=(pattern=solid thickness=9);
  scatter x=name y=height / group=name markerattrs=(symbol=circlefilled size=20);
  yaxis offsetmin=0;
  run;

Thirteen.png

Frequent Contributor
Frequent Contributor
Posts: 132

Re: Differentiate line thickness/marker size in sg template w/ graphdata elements

On another note is there also another way to set it so that a color does not repeat the original graphdata element w/o specifying every color? I see a repeating black color.

Thanks

Lawrence

Post a Question
Discussion Stats
  • 8 replies
  • 631 views
  • 3 likes
  • 3 in conversation