Error in histogram plot including datetime

1 次查看(过去 30 天)
Hi!
I want to plot a histogram in a plot which x-axis is a datetime vector. However i got this error:
Error in histogram (line 145)
[opts,passthrough,dispatch] = parseinput(args,firstaxesinput);
here is my code:
histogram(run(1:12), D1.Date(1:12));
the run vector is double and D1.Date is a datetime vector.
12×1 datetime array
1999-12-31
2000-01-03
2000-01-04
2000-01-05
2000-01-06
2000-01-07
2000-01-10
2000-01-11
2000-01-12
2000-01-13
2000-01-14
2000-01-18
any solution would be much appritiated.

回答(1 个)

Star Strider
Star Strider 2019-1-20
You already appear to have the data you want to plot, so histogram may not be the correct choice.
Try this instead:
figure
bar(D1.Date(1:12), run(1:12))
That will plot your data to look like a histogram plot.

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by