Stuart’s MATLAB Videos

Watch and Learn

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

Paul Q. replied on : 1 of 6

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!

Dajuma replied on : 3 of 6

I’m using matlab version 2014a and I accounted some problems .I used
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.

Stuart McGarrity replied on : 5 of 6

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

Add A Comment

Your email address will not be published. Required fields are marked *

What is 7 + 10 ?

Preview: hide