Stuart’s MATLAB Videos

Watch and Learn

MATLAB: Setting custom tick labels 6

Posted by Doug Hull,

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.

6 CommentsOldest to Newest

Scott replied on : 1 of 6
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?
Scott replied on : 2 of 6
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).
Barry replied on : 3 of 6
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.
dhull replied on : 4 of 6
@Barry. Here is a workaround/explanation. Doug
Pawel replied on : 5 of 6
Why make people watch a video of you typing those commands?? A snippet of code and some comments in an article would be much more useful.
Abbas replied on : 6 of 6
Dear Doug, Thank you very much. I really needed to know this. And I'm happy that it can be found as the first search result in Google. Abbas