2
$\begingroup$

This question already has an answer here:

When I type

ContourPlot[x == Sin[6*Pi*y], {x, -1, 1}, {y, -2, 2}]

I get this

Penis

Now I'm not a particularly gifted mathematician, but I have a feeling this just might be wrong. How do I get Mathematica to plot it correctly?

$\endgroup$

marked as duplicate by Mr.Wizard Feb 1 '15 at 1:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ closely related: 31164 $\endgroup$ – Kuba Jan 31 '15 at 18:08
  • $\begingroup$ I'm gathering you're new to Mathematica. Is this plot truly what you were seeking? You're plotting a logical (Boolean) function--i.e., one that has output TRUE or FALSE. I suspect you wanted to plot $Sin[6 \pi y]$ or something like that. $\endgroup$ – David G. Stork Jan 31 '15 at 18:45
  • $\begingroup$ @DavidG.Stork Yes, I wanted to plot $x = Sin [6 \pi y]$, this should have worked in theory though $\endgroup$ – user85798 Jan 31 '15 at 19:42
  • $\begingroup$ @LTS A much better way is $Plot[Sin[6 \pi y], \{y, -2,2\}]$... You don't have to specify the range of the output; it generalizes to other functions immediately; it is understood by others better, and on and on. Another question to you: Do you really want to be the $.00001\%$ of cases where you plot $x$ as a function of $y$, instead of the standard $y$ versus $x$ used in every textbook and technical presentation? $\endgroup$ – David G. Stork Jan 31 '15 at 20:02
  • $\begingroup$ @DavidG.Stork No, I want to plot the inverse of $\sin[6\pi x]$. I could write it as an explicit function of x, but that would be rather difficult since it's not a proper function. $\endgroup$ – user85798 Jan 31 '15 at 20:42
1
$\begingroup$

ContourPlot is not as smart as you so you have to give it more PlotPoints to sample domain or use more suited for this job function:

ParametricPlot[{Sin[6*Pi*y], y}, {y, -2, 2}]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you, I did not know about ParametricPlot. $\endgroup$ – user85798 Jan 31 '15 at 18:31
1
$\begingroup$
ContourPlot[x == Sin[6*Pi*y], {x, -1, 1}, {y, -2, 2}, PlotPoints -> 100]
$\endgroup$
1
$\begingroup$

Just increase MaxRecursion to track the curve correctly

ContourPlot[x == Sin[6*Pi*y], {x, -1, 1}, {y, -2, 2}, MaxRecursion -> 3]

enter image description here

Usually PlotPoints and MaxRecursion options solve almost all resolution problems.

$\endgroup$

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