0
$\begingroup$

If I have the following,

    DensityPlot[x Sin[y], {x, -5, 5}, {y, -5, 5}, Frame -> False, 
 Axes -> True, AxesStyle -> {Red, Blue}]

and the output is

enter image description here

is there any way I can change the axes ticks. let's say 2 to 4 and 4 to 6, without changing the x and y range in the code x Sin[y], {x, -5, 5}, {y, -5, 5}. By only using axes command such as changing axes on the existing output Axes -> 2 to 4 and 4 to 6.

$\endgroup$
2
  • 2
    $\begingroup$ is there any way I can change the axes ticks. let's say 2 to 4 and 4 to 6, without changing the x and y range in the code not clear what you mean, since the labels already show 2,4. But you can always play with the option Ticks -> {Range[-5, 5, 1], Automatic} and change the labels any way you want. see help on Ticks $\endgroup$
    – Nasser
    Commented Feb 15, 2023 at 13:13
  • 1
    $\begingroup$ Study the helpfile on Ticks. You can place any label at any value with Ticks->{{{xvalue,xlabel},...},{{yvalue,ylabel},...}}. Two lists of pairs of values and labels. $\endgroup$
    – Nicholas G
    Commented Feb 15, 2023 at 14:31

1 Answer 1

1
$\begingroup$
DensityPlot[x Sin[y], {x, -5, 5}, {y, -5, 5}, Frame -> False, 
 Axes -> True, AxesStyle -> {Red, Blue}, 
 Ticks -> {{{-4, -6}, {-2, -4}, {2, 4}, {4, 
     6}}, {{-4, -6}, {-2, -4}, {2, 4}, {4, 6}}}]

enter image description here

$\endgroup$

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.