How to Control Tick Precision in ListLinePlot?

How can I control the number of decimal places the ticks show along the horizontal and vertical axes? I have tried various approaches but ListLinePlot seems to automate it.

     r=2;NN=10;y0=0.1;
sol = RecurrenceTable[{y[k + 1] == r*y[k]*(1 - y[k]), y[0] == y0}, y, {k, 0, NN}]; AA = ListLinePlot[sol, Mesh -> All, AxesOrigin -> {-1, 0},  DataRange -> {0, NN} ,
PlotStyle -> {{Thickness[0.0015], Blue}, PointSize[0.021]}];
BB = Plot[(r - 1)/r, {x, 0, NN}, PlotStyle -> {{Thickness[0.0025], Red}}];
Show[AA, BB, Ticks -> {Range[0, NN, 1], Range[0, 1, 0.05]}]


To control the number of decimal places displayed on the horizontal and vertical axes in a ListLinePlot or any other plot in Mathematica, you can use the NumberForm function within the Ticks option. Here's how you can modify your existing code to control the number of decimal places for the tick labels:


r = 2; NN = 10; y0 = 0.1;

sol = RecurrenceTable[{y[k + 1] == r*y[k]*(1 - y[k]), y[0] == y0},
y, {k, 0, NN}];

AA = ListLinePlot[sol, Mesh -> All, AxesOrigin -> {-1, 0},
DataRange -> {0, NN},
PlotStyle -> {{Thickness[0.0015], Blue}, PointSize[0.021]},
Ticks -> {Automatic,
Table[{i, NumberForm[i, {2, 1}]}, {i, 0, 1, 0.05}]}];

BB = Plot[(r - 1)/r, {x, 0, NN},
PlotStyle -> {{Thickness[0.0025], Red}}];

Show[AA, BB, Ticks -> {Range[0, NN, 1], Range[0, 1, 0.05]}]

• wonderful ... many thanks Athanasios! Sep 5, 2023 at 13:18

Use pairs of values and print formats eg

ListLinePlot[Array[({#*\[Pi]/77.2, 12 E^(1/#)} &), {22}],
Ticks ->
{({#, Style[ScientificForm[ #, 3], 6]} &) /@  Range[0, 1,  0.3389076],
({#, Style[AccountingForm[ #, {4, 2}], 4]} &) /@ Range[10, 20, 0.987654321]}]


• How to apply this to my code? Sep 5, 2023 at 10:43