Skip to content
Prev 405 / 885 Next

Shading the solution of quadratic inequality

I'm not sure exactly what sort of plot was desired, but I'll offer 1.5  
possibilities.

Currently you can do something like this:

require(mosaic)
plotFun( x^2 - 4 ~ x , xlim=c(-6,6), col='blue' )
plotFun( (x^2 - 4)/as.numeric(x^2 -4 > 0) ~ x , xlim=c(-6,-2),  
add=TRUE, col='blue', lwd=4 )

It is a bit of kludge since I'm using division by 0 to hide part of  
the function.  You can adjust colors, line thickness, and alpha to  
your particular sensitivities.  And you can use type='h' if you want a  
"filled in version".

Soon, you should be able to do

plofFun( x^2 - 4 ~ x, groups=(x^2-4>0) )

If you find yourself wanting to plot "mathematical" functions like  
this, I encourage you to give plotFun() a try and let us know how you  
like it.

---rjp
On Feb 16, 2012, at 9:42 AM, R. Michael Weylandt wrote: