Document 618

Shading regions in graphs

Version: 4.x & 5.0 - Scientific WorkPlace & Scientific Notebook

You can shade regions in SWP and SNB plots by creating quasi space-filling curves. The method we illustrate with the first example below works on regions where $y=g(x)$ is the bottom curve. The second example illustrates shading a region below $y=f(x)$. Adapt the methods to your needs.


Example of a shaded plot

  1. From the Tools menu, choose Computation Setup.
  2. Choose Plot Behavior, select Recompute Plot When Definitions Change, and choose OK.
  3. Define $f(x)=\sin x$ and plot the function.
  4. Define $g(x)=3\sin x$.
  5. Select $g(x)$ and drag it onto the plot.
  6. Define $M=643$ or choose some other high number.
    You may need to experiment to find an appropriate number for your needs.
  7. Select the plot and choose Properties to open the Plot Properties dialog.
  8. For each expression, set the plot color and line thickness you want.
    In this example, we plotted $\sin x$ and $g(x)$ with a thin gray line.
  9. Add four new expressions to the plot:
    MATH
    MATH
    MATH
    MATH
  10. For the first new expression,
    1. Use the Item Number box to select the expression.
    2. Set the plot color you want.
    3. Set the line thickness to Thick.
    4. Choose Variables and Intervals.
    5. Set the $x$ interval to -3.14 to 0.
    6. In the Points Sampled box, enter 875 or some other number greater than $M$ and less than 1000.
      Again, you may need to experiment to find an appropriate number of samples.
    7. Choose OK.
  11. Repeat step 8 for the other three new expressions, setting the $x$ intervals to 0 to 3.14, -5 to -3.14, and 3.14 to 5, respectively.
  12. Choose OK.

You can use the same process to shade a region below $y=f(x)$. For $g(x)$ use a constant value less than the minimum value of $y$ for the plot. Here we used $g(x)=-9$ and set $M=300$.


Example of shaded plot



Last revised 07/14/07