1
$\begingroup$

I am using the following code in Mathematica 8.0

DensityPlot[Sin[5 x], {x, -10, 10}, {y, -10, 10}, PlotRange -> All]

The plot should clearly be independent of y, but the result I am getting is

enter image description here

Is there any way to fix this with this version of Mathematica? Am I doing something wrong?

$\endgroup$
2
  • 4
    $\begingroup$ just add PlotPoints -> 50 - the resolution isn't high enough by default. $\endgroup$
    – Jens
    Commented Feb 16, 2016 at 16:50
  • 1
    $\begingroup$ Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – user9660
    Commented Feb 16, 2016 at 17:03

1 Answer 1

3
$\begingroup$

The problem is the default number of points been a small number (as pointed out by @Jens). You can define the number of points using PlotPoints or let Mathematica decide by itself where more points are needed by allowing a larger MaxRecursion. I favour the later.

DensityPlot[
 Sin[5 x]
 , {x, -10, 10}
 , {y, -10, 10}
 , PlotRange -> All
 , MaxRecursion -> 5
 ]

enter image description here

$\endgroup$
1
  • 2
    $\begingroup$ ...and you can even set both MaxRecursion and PlotPoints if you're feeling adventurous. ;) $\endgroup$ Commented Feb 16, 2016 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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