4
$\begingroup$

How does one color the interior of the elongated circular region in the following figure:

ContourPlot[y^2 - x (x - 1)(x - 3) == 0, {x, -2, 7}, {y, -4, 3}]
$\endgroup$

2 Answers 2

2
$\begingroup$

Try without "==0"

ContourPlot[y^2 - x (x - 1) (x - 3), {x, -2, 7}, {y, -4, 3}]

enter image description here

$\endgroup$
1
  • $\begingroup$ But I need only the curve not the surface $\endgroup$
    – Sara yaqob
    Mar 24, 2019 at 20:47
5
$\begingroup$

Your plot

c = ContourPlot[y^2 - x (x - 1) (x - 3) == 0, {x, -2, 7}, {y, -4, 3}]

enter image description here The region you would like colored

R = RegionPlot[y^2 - x (x - 1) (x - 3) < 0 && x < 2, {x, -2, 7}, {y, -4, 3}]

enter image description here

Both plotted together

Show[c, R]

enter image description here

$\endgroup$
5
  • 1
    $\begingroup$ Thank you so so much sir. That's what I need. $\endgroup$
    – Sara yaqob
    Mar 24, 2019 at 20:50
  • $\begingroup$ @Sara, You are welcome! $\endgroup$
    – mjw
    Mar 24, 2019 at 20:52
  • 2
    $\begingroup$ @Sarayaqob you mistakenly accepted my answer $\endgroup$
    – Xminer
    Mar 24, 2019 at 21:05
  • 1
    $\begingroup$ That's okay. Anyway, your answer works. One question is whether or not we can color in the round area only using ContourPlot[]. $\endgroup$
    – mjw
    Mar 26, 2019 at 17:11
  • $\begingroup$ You can color the RegionPlotwith PlotStyle, e.g. R = RegionPlot[ y^2 - x (x - 1) (x - 3) < 0 && x < 2, {x, -2, 7}, {y, -4, 3}, PlotStyle -> Yellow] $\endgroup$
    – rmw
    Apr 4, 2019 at 17:08

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.