Feed on
Posts
Comments

matlab will automatically calculate how many tick marks produce the most pleasing axes in a plot.  however, if you know better, you can override these settings by commanding:

>> set(gca,’XTick’,[1:tick_number])


Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

One Response to “force a number of tick marks in a matlab plot”

  1. on 27 Nov 2012 at 7:06 am Wauzl

    Sorry to say this, but you really got this wrong: XTick sets the location of the ticks, not the number of ticks. If you do
    >> plot(-3,-2)
    >> set(gca,’XTick’,1:3)
    you won’t see any ticks on the x-axis, because Matlab tries to make ticks at x=1,2,3. But this is not visible in the current plot, so no ticks are produced.

Did I get this wrong? Let me know!

Trackback URI | Comments RSS

More blogs about http://desk.stinkpot.org:8080/tricks.