MATLAB Answers


Manually Xtick control by edit field

Asked by Hello kity on 16 Jan 2013

I want to manually control the x step size (xticks).

there is a edit field which determines the x step size:


this is what i have now

                if ~isnan(xstep1)   
                xbounds = xlim;

hope it helps someone



No products are associated with this question.

1 Answer

Answer by Jing
on 16 Jan 2013
 Accepted answer


You're just trying to change the default XTick position or the XTickLabel? These two is different properties.

My suggestion is first plot a simple figure then using the edit tool in the figure to change whatever you want, and you can get the m-code after the changes. At this point you will know the exact code that meets your need. Here's the steps you can follow:

1. plot(1:10,1:10);

2. click Edit->Axes Properties...on the Figure menu, and click Ticks...button on the opened property panel.

3. Change what you want, then click File->Generate Code on the figure menu.


thank you , I edited my first post.

new question for now:

Matlab creates lines at each xtick, except if there is data in it (graph), now i have to find out how still to show the line even if there is a graph in it.

on 16 Jan 2013

What do you mean by graph? a picture? or a shape?

I think you should ask a new question if it's totally a different one from this theme, or others won't notice.

example you make a bar graph.

lets say, at 1 there is no bar, so you see a short line at xtick 1, at 2 there is a value so it creates a bar , then that line disappears..

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!