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.
By
Doug Hull
Doug first used MATLAB in 1994, could not figure it out until he got some help in 1995. He is now dedicated to making sure that no one else wastes a year of their life not knowing MATLAB like he did.
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?
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).
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’});
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?
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).
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.
@Barry.
Here is a workaround/explanation.
http://www.mathworks.com/support/solutions/en/data/1-5HAF0I/?solution=1-5HAF0I
Doug
Just wanted to give you a shout from the valley of Nike Air Jordansthe sun, great information. Much appreciated.