Stuart’s MATLAB Videos

Using Datetick with Plotyy in MATLAB 6

Posted by Doug Hull,

Recently, I needed to plot two different sets of time series data on the same axes, but they were at different scales. In this simplified example, I show how you can change the x-labels to display the month name. This requires you capture the handles of the axes created by plotyy, then send them to datetick explicitly.

6 CommentsOldest to Newest

Thank you so much for the great videos Doug! I was wondering how you knew the number of input arguments in this video in order to grab the axis handle. I seem to have trouble understanding how to understand the documentation on plotting handles. Any direction you can provide is appreciated. Thank you again!

I’m using matlab version 2014a and I accounted some problems .I used
set(gca,’XTick’,x1)
datetick(‘x’,’mmm’,’keepticks’) to have the months in x axis but I’m getting only Jan in the whole axis so I don’t know what to do and I’m asking for help.
Thanks

Hi Dajuma, What range of values do you have in your x-axis and in x1? Can you provide your code?

Add A Comment

What is 2 + 6?

Preview: hide

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