# Problem with tick mark position

I am plotting this piecewise function:

$$\rho (x,0) = \rho_{max} \text{ if } x \leq 0$$ $$\rho (x,0) = 0 \text{ if } x>0.$$

I used this code

Plot[Piecewise[{{pmax, x <= 0}, {0, x > 0}}], {x, -2000, 2000},
Axes -> True, AxesLabel -> {"x", "\[Rho]"},
Ticks -> {{0}, {{2000, "pmax"}}}, PlotStyle -> Thickness[0.01]]


and I get this:

Is it possible to move the tick label $\rho_{max}$ to the right?

• Yeah. Look at the examples for Ticks in Plot. Dec 15, 2017 at 2:31
• You have a syntax error (extra comma). Dec 15, 2017 at 2:33
• @DavidG.Stork Thanks, but that was a mistake I made copying. My original code was fine. Dec 15, 2017 at 2:38
• Also... don't you need to specify pmax = 2000? Dec 15, 2017 at 2:39
• @DavidG.Stork Sorry, I forgot to copy it because in the nb is separeted somewhere else. Dec 15, 2017 at 2:42

## 1 Answer

I would use Epilog instead of trying to hack the Ticks option to move the tick label to the right:

Plot[
Piecewise[{{2000, x<=0}, {0, x > 0}}],
{x, -2000, 2000},
Axes->True, AxesLabel->{"x","\[Rho]"},
Ticks->None, Epilog->Text["pmax", Offset[{20, 0}, {0,2000}]],
PlotStyle->Thickness[0.01]
]


• Thank you very much!!! Dec 15, 2017 at 2:49