Using Datetick with Plotyy in MATLAB6

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.

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!

Doug replied on : 2 of 6

http://www.mathworks.com/help/rf/plotyy.html

I just scanned through the first part of the documentation page looking for the one that had the function signature I was looking for. I am not sure why I chose to use the ~ to ignore the second and third arguments. I could have just asked for a single output.

Dajuma replied on : 3 of 6

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

Dajuma replied on : 4 of 6

I also want to use my how step for the Y axis but I was able only to set the Xlim and Ylim

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?

Lisa replied on : 6 of 6