Doug's MATLAB Video Tutorials

July 23rd, 2010

MATLAB: Setting custom tick labels

This short video shows how to change the tick labels on a plot. You might want to do this for bar plots, or just a regular plot that you want to customize.

5 Responses to “MATLAB: Setting custom tick labels”

  1. Scott replied on :

    I’m sure this must be posted somewhere, but I’ve looked and can’t seem to find the answer anywhere.

    I’m trying to create a basic line plot of a stock’s price. The normal 2d plot correctly puts the price on the y axis, but it puts a count (e.g., 1 2 3 4 5…# of obs) on the x axis. I’d like to have the actual dates associated with each price put on the x axis. My data matrix includes the Matlab number representing the date in column 1 and the stock’s price for each date in column 2. I’ve even converted the Matlab date number into standard date strings (e.g., 7-Aug-2010). How do I get the dates in column 1 (or the date strings created from column 1′s date number) to be used as tick labels on the x axis in the plot?

  2. Scott replied on :

    Ugh. I knew there was something simple I was missing. I just found the “finchart” command (actually, I had looked at this before, but for some reason its existence slipped my mind recently). I’m looking through the m file now (assuming I’ll find the answer to my question there).

  3. Barry replied on :

    Hallo Doug,

    I tried to use this trick and it works properly except when I try to use Greek alphabet. for example:
    set(gca, ‘XTickLabel’, {‘X’,'U’,'L’,'\Gamma’,'X’,'W’,'K’});

    can you explain how to fix it?

    Thank you very much.

  4. dhull replied on :

    @Barry.

    Here is a workaround/explanation.

    http://www.mathworks.com/support/solutions/en/data/1-5HAF0I/?solution=1-5HAF0I

    Doug

  5. Nike Air Jordans replied on :

    Just wanted to give you a shout from the valley of Nike Air Jordansthe sun, great information. Much appreciated.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks

Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.

Doug's picture

These postings are the author's and don't necessarily represent the opinions of The MathWorks.