Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.