9
$\begingroup$

I want to draw a parametric equation with ± like the figure below:

enter image description here

But I don't get the result I want when I run the following code. What can I do to get it?

ParametricPlot[{x, ±x^2}, {x, 0, 1}, 
  Mesh -> 30, PlotPoints -> 50, AxesOrigin -> {0, 0}]
$\endgroup$
  • 10
    $\begingroup$ PlusMinus is for display purposes. It has no builtin meaning. It is not an operator that returns a value. The plot would normally be produced with Plot[{x^2, -x^2}, {x, 0, 1}, Mesh -> 30, AspectRatio -> 2, PlotStyle -> {RGBColor[0.37, 0.51, 0.71]}] but you could use ParametricPlot[{Abs[x], Sign[x] x^2}, {x, -1, 1}, Mesh -> 60, PlotPoints -> 50, AxesOrigin -> {0, 0}] $\endgroup$ – LouisB Mar 28 at 0:07
  • $\begingroup$ @LouisB Thank you. I just want to know if MMA has similar multivalued functions participating in drawing. $\endgroup$ – Please Correct GrammarMistakes Mar 28 at 1:24
16
$\begingroup$

This formulation might be useful to you.

±b_ := {b, -b}

ParametricPlot[Thread[{x, ±x^2}], {x, 0, 1}, Mesh -> 30, 
 PlotPoints -> 50, AxesOrigin -> {0, 0}]

enter image description here

Notes

  • This will expand appearances of ±value outside of plotting as well. If you need ± to persist in data this expansion should be restricted. We can write a custom plotting function, say parametricPlot, that performs this and other expansions, then hands off the data to ParametricPlot.

  • The form used above results in shared styling between the positive and negative branches. Reference: Plot draws list of curves in same color when not using Evaluate

| improve this answer | |
$\endgroup$
8
$\begingroup$

You can just do

ParametricPlot[{{x, x^2}, {x, -x^2}}, {x, 0, 1}, Mesh -> 30, 
 PlotPoints -> 50, AxesOrigin -> {0, 0}]

Mathematica graphics

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.