I have a plot with dates in form of mm/dd
as x-axis data. Now I have
xData = ["01/22" "01/23" "01/24" "01/25" "01/26" "01/27" "01/28" "01/29"]
which is a string array of size 1 x 8
.
How do I plot with
yData = [557 655 941 1433 2118 2927 5578 6167]
by using something like
plot(xData, yData)
with ["01/22" "01/23" "01/24" "01/25" "01/26" "01/27" "01/28" "01/29"]
as the x-axis tick labels?
Currently I got the error messages Error using plot. Not enough input arguments.
when running plot(xData, yData)
as above, which I don't know what it exactly means.
CodePudding user response:
I can think of two possibilities:
Convert the xData into a datetime array and use it in the plot
plot(datetime(xData, 'InputFormat', 'MM/dd', 'Format', 'MM/dd'), yData)
Use xData as the label of the x axis:
plot(yData) set(gca, 'XTick', 1:length(yData), 'XTickLabel', xData)