lout-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drawing Normal Graphs - Shading not consistent


From: Albert Kinderman
Subject: Drawing Normal Graphs - Shading not consistent
Date: Mon, 07 Apr 2003 08:45:53 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i386; en-US; rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3

Hi:

I teach statistics and find it useful to draw graphs of the normal distribution with certain areas filled in (shaded). I have tried to create a def that will produce the shaded graph. What follows is my mydefs file and a sample document.

The problem is that sometimes the shading goes all the way to the upper limit and sometimes it stops short. Note, because I step through the graph by .1, both the lower and upper arguments should be rounded to the nearest .1.

Does anyone have any suggestions?



[file mydefs]

import @Graph @Data

def @NormalDensity
        right x
        { {1/{sqrt 2*pi}}*e exp {-.5*x*x}}

def @NormalFilledGraph left low right high
{ @Graph
        style { axes }
        belowgap {0}
        xorigin {0}
        yorigin {0}
        xmin {-2.5}
        xmax {2.5}
        ymin {0}
        xticks {}
        yticks {}
        yextra {0}
        height {2 cm}
{       
        @Data   pairs {solid}
                paint {yes}
                color {lightgrey}
        {xloop from {low} to {high} by {.1} do
                {x @NormalDensity x}}   
        @Data   pairs {solid}
        {xloop from {-2.5} to {2.5} by {.1} do
                {x @NormalDensity x}}   
        @Data   pairs {solid}
                {low 0 low  @NormalDensity low}
        @Data   pairs {solid}
                {high 0 high @NormalDensity high}
}
}


[sample document]

@SysInclude { graph }
@SysInclude { doc }

@Doc
@Text
        @Begin
@CD   .6 @NormalFilledGraph 1.4

@CD -2.5 @NormalFilledGraph .3

@CD   .3 @NormalFilledGraph .7

@CD  -.6 @NormalFilledGraph .5

        @End
@Text


reply via email to

[Prev in Thread] Current Thread [Next in Thread]