How to modify a time series plot
조회 수: 4 (최근 30일)
이전 댓글 표시
I have created a time series plot. My x axis shows the dates that correspond with each point as intended, however, it is only showing four dates. For this particular data file, there are 17 dates. Is there a way to change the way the date values show up?
댓글 수: 0
채택된 답변
dpb
2018년 8월 15일
You can set the tick locations and formatting as desired; you'll may have to rotate to get enough room for as much as you're wanting to show to be legible; dates/times take up a lot of real estate.
댓글 수: 2
dpb
2018년 8월 15일
Well, approximately log-distributed times on a datetime axes seems a little unusual...bet nobody at TMW ever thought of somebody having data that looked like that! :)
What you need to do is to set the XTick values to a set across the axes limits instead of using every observed value -- ticks and data points don't have to coincide.
Try something like (air code, don't have your data to play with but should work I believe)
xtk=xlim; % retrieve default axes limits
Ntk=10; % pick a number of ticks desired
ax.XTick=linspace(xtk(1),xtk(2),Ntk);
Salt to suit.
I not used the timeseries object enough to know and the doc was pretty obtuse; does it store the times as explicit field or is buried in the properties and in your creation as above are the values of
GAUGE_ts.Time
datetimes equiavelent to Dates? I'm presuming that's so in which case you could eliminate creating the other variable as a minor efficiency.
If you want the axes limits different, just do the same thing as above to set the axis limits; and then set the ticks to match.
It does seem as though a useful enhancement would be to be able to specify number of major ticks as well rather than requiring the tick values...
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!