empty space between values when making bar chat with datetime
조회 수: 7 (최근 30일)
이전 댓글 표시
I'm trying to make a stacked bar chat with some value on the y-axis and time on x-axis using datetime.
An example of my data:
2008-Jan-14 15:00:00 0 69 1154 1444.8
2008-Mar-01 13:00:00 0 69 1098 1375.8
2008-Jun-24 15:00:00 0 70 105 399.3
2008-Aug-30 12:00:00 0 68 168 710.5
2008-Sep-14 19:00:00 338 69 638 1614.3
2008-Dec-11 20:00:00 525 69 100 1000.3
The problem is, because of the many days between my values, there is a huge gap in my plot and I can barely even see the bars. So is there a way to remove the negative space while still using datetime on my x-axis?
Thanks in advance.
댓글 수: 0
답변 (1개)
Eric Sofen
2020년 6월 26일
That's a tough one. Obviously, if you were doing a standard x-y plot, you'd want the datetime axis to realistically represent time. Similarly, if you are doing a bar chart with fairly densely/uniformly spaced data.
In this case, perhaps the best bet is to plot against 1:numel(dates) and then update the axis labels with text representations of the timestamps:
t = datetime+calmonths([0 3 4 5 11 12]);
data = rand(size(t));
bar(1:numel(t),data)
xticklabels(string(t))
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Bar Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!