Histogram with gplot

  • Follow


Hello

I would like to create a histogram with several variables plotted
against the horizontal variable. Now, this can be done using gplot and
a wide needle; something like the following:

    symbol1 i=needle v=none w=32 color=red;
    symbol2 i=needle v=none w=32 color=blue;

    proc gplot data= bot;
        plot verticalvar*horizontalvar=groupvar;
    run;

However, when running this code, the automatically created horizontal
line at 0 on the vertical axis takes the width specified for symbol1.
With, say, w=32, the graph looks rather unattractive. The only way I
could see how to circumvent this, is to create dummy observations with
value 0, let symbol1 map to those, and set symbol1 w=1. However, is
there a cleaner way to code a thin horizontal line?

Thanks  for any input.
Soeren Hvidkjaer
0
Reply hvidkjaer (4) 5/26/2010 9:07:44 AM

On May 26, 11:07=A0am, "hvidkj...@gmail.com" <hvidkj...@gmail.com>
wrote:
> Hello
>
> I would like to create a histogram with several variables plotted
> against the horizontal variable. Now, this can be done using gplot and
> a wide needle; something like the following:
>
> =A0 =A0 symbol1 i=3Dneedle v=3Dnone w=3D32 color=3Dred;
> =A0 =A0 symbol2 i=3Dneedle v=3Dnone w=3D32 color=3Dblue;
>
> =A0 =A0 proc gplot data=3D bot;
> =A0 =A0 =A0 =A0 plot verticalvar*horizontalvar=3Dgroupvar;
> =A0 =A0 run;
>
> However, when running this code, the automatically created horizontal
> line at 0 on the vertical axis takes the width specified for symbol1.
> With, say, w=3D32, the graph looks rather unattractive. The only way I
> could see how to circumvent this, is to create dummy observations with
> value 0, let symbol1 map to those, and set symbol1 w=3D1. However, is
> there a cleaner way to code a thin horizontal line?
>
> Thanks =A0for any input.
> Soeren Hvidkjaer

Actually, my understanding of the functionality was not correct.
Consider the following example:

data a;
    do tmpvar =3D 1 to 10;
        do groupvar =3D -1 to 1;
            hvar =3D tmpvar+groupvar*.1;
            vvar =3D ranuni(0)-.5;
            output;
        end;
    end;
run;

symbol1 i=3Dneedle v=3Dnone w=3D1 color=3Dred;
symbol2 i=3Dneedle v=3Dnone w=3D1 color=3Dred;
symbol3 i=3Dneedle v=3Dnone w=3D32 color=3Dblue;

options orientation =3D landscape
    papersize =3D letter;

ods trace on;

ods select Gplot;

ods pdf file=3D"histogram.pdf";
proc gplot data=3D a;
    plot vvar*hvar=3Dgroupvar;
run;
quit;
ods pdf close;

Having run this with different widths in the symbol statements, it
seems that the only combination that yields a thin horizontal line at
zero is the one with w=3D1 in symbol1 and symbol2. For instance,

symbol1 i=3Dneedle v=3Dnone w=3D1 color=3Dred;
symbol2 i=3Dneedle v=3Dnone w=3D32 color=3Dred;
symbol3 i=3Dneedle v=3Dnone w=3D32 color=3Dblue;

or

symbol1 i=3Dneedle v=3Dnone w=3D1 color=3Dred;
symbol2 i=3Dneedle v=3Dnone w=3D32 color=3Dred;
symbol3 i=3Dneedle v=3Dnone w=3D1 color=3Dblue;

would yield a thick horizontal line. Any insight into the mapping of
needle width into horizontal line width would be much appreciated.

Thanks
Soeren
0
Reply hvidkjaer 5/26/2010 1:52:08 PM


1 Replies
1193 Views

(page loaded in 0.091 seconds)

Similiar Articles:













7/22/2012 8:40:14 AM


Reply: