Description
Here we will graph the inequality
(1)Sage doesn't have a specific function to plot an inequality, so instead we will be plotting $y = 1 - x^2$ and shading all points that violate the inequality. To shade, we will set the fill, fillcolor and fillalpha parameters. fill fills from the y-value specified to the curve, fillcolor sets the color being used to fill and fillalpha sets how transparent the fill will be. We will also set ymin and ymax, otherwise Sage will plot from y = 10 to the local minima.
Sage Cell
Code
plot(1 - x^2, (x, -2, 2), gridlines='minor', ymin=-2, ymax=2, fill=10, fillcolor='yellow', fillalpha=2/3)
Options
Filling under the curve
We can fill under the curve by setting fill to a y-value below the curve instead of above. We will use -10 instead of 10.
Code
plot(1 - x^2, (x, -2, 2), gridlines='minor', ymin=-2, ymax=2, fill=-10, fillcolor='yellow', fillalpha=2/3)
Tags
Primary Tags: Plotting: Two-dimensional plots
Secondary Tags: Two-dimensional plots: Plotting Inequalities
Related Cells
- Plotting a Circle
- Plotting a Polygon
- Plotting an Implicit Function
- Two-Dimensional Plots
- Parametric Plots
- Line Plots
- Plotting Two-Dimensional Vector Fields
- Multiple Plots on the Same Graph
- Controlling the Viewing Window of a Plot
- Plotting Functions with Asymptotes
- Multiple Annotation Techniques for Graphing
- Occasional Issues in Polar Plotting.
- Constructing Contour Plots in Sage
- Plotting Systems of Linear Inequalities
- Plotting Nonlinear Inequalities in Sage
- Making log-log Plots in Sage
Attribute
Permalink:
Author: Gregory V. Bard. Sage for Undergraduates. American Mathematical Society, Providence, RI, 2015. Available at http://www.gregorybard.com/Sage.html.
Date: 02 Mar 2019 21:20
Submitted by: Zane Corbiere