[英]Plot date labels in x-axis [MATLAB]
I have a plot with dates in form of mm/dd
as x-axis data.我有一个 plot,日期以
mm/dd
的形式作为 x 轴数据。 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
.这是一个大小为
1 x 8
的字符串数组。
How do I plot with我如何使用 plot
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?用
["01/22" "01/23" "01/24" "01/25" "01/26" "01/27" "01/28" "01/29"]
作为 x 轴刻度标签?
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.目前我收到错误消息
Error using plot. Not enough input arguments.
运行plot(xData, yData)
时,我不知道它的确切含义。
I can think of two possibilities:我可以想到两种可能性:
Convert the xData into a datetime array and use it in the plot将 xData 转换为日期时间数组并在 plot 中使用它
plot(datetime(xData, 'InputFormat', 'MM/dd', 'Format', 'MM/dd'), yData)
Use xData as the label of the x axis:使用 xData 作为 x 轴的 label:
plot(yData) set(gca, 'XTick', 1:length(yData), 'XTickLabel', xData)
plot(datetime(xData, 'InputFormat', 'MM/dd', 'Format', 'MM/dd'), yData)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.