2
$\begingroup$

I'm trying to augment the x axis of a listplot to fit the number of steps. Secondly, since there are a large number of steps (50), there will be 50 ticks which will make the graph messy. How do I get the x-axis to show ticks from 0 to 5 in steps of 1 instead of 0.1?

t1 = Table[
  FindRoot[({y2 + x2 } /. x2 -> pp ) == 10 , {y2, 5}], {pp, 0, 5,0.1}]
ListPlot[y2 /. t1]

enter image description here

xcoord = Transpose[{Table[ppp, {ppp, 0, 5}]}, {t1}]
ListPlot[y2 /. t1, Ticks -> {First /@ xcoord}]
$\endgroup$
1
$\begingroup$
t1 = Table[FindRoot[({y2 + x2} /. x2 -> pp) == 10, {y2, 5}], {pp, 0, 5,   0.1}]; 
ListPlot[(Last @@@ t1), Ticks -> {Range[0, 5, 1], Automatic}, DataRange -> {0, 5}]

enter image description here

Alternatively, if want to show part of the data (say, only 6 points) you can use

ListPlot[(Last @@@ t1)[[;; ;; 10]], Ticks -> {Range[0, 5, 1], Automatic}, DataRange -> {0, 5}]

to get

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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