Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem in plotting a function. The example code is as following:

d = 0.1;
M[x_] := ((x/d) - 0.4);
Plot[p[x], {x, 0, 10}, Ticks -> {{0, d, 2d, 3d}, {1, 1}}] 

I would like to have $d,\ 2d,\ 3d$ and so on the x-axis label at right positions, i.e. at $0.1,\ 0.2$ and so on. How can I achieve this?

share|improve this question

You mean something like this? (ps. I assume your M[x_] is meant to be p[x]

 tick[min_, max_] := 
  Table[{i, Row[{Rationalize[i/d], "d"}], {.01, 0}, Black}, {i, 
    Ceiling[min], Floor[max], 10*d}];
d = 0.1;
maxRange = 10;
p[x_] := ((x/d) - 0.4);
Plot[p[x], {x, 0, maxRange}, Frame -> True, 
 FrameTicks -> {{Automatic, None}, {tick, None}}, 
 GridLines -> {Range[0, 10], Automatic}, GridLinesStyle -> LightGray]

enter image description here

You can play with the tick styling as you want, change the number formatting, etc...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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