フィルターのクリア

How to modify a time series plot

4 ビュー (過去 30 日間)
Brandon Bush
Brandon Bush 2018 年 8 月 15 日
コメント済み: dpb 2018 年 8 月 15 日
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?

採用された回答

dpb
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 件のコメント
Brandon Bush
Brandon Bush 2018 年 8 月 15 日
Thanks, that definitely helped. I would now like to put equal spacing between each tick mark, however, there is no function to specify the spacing on that page. How can I do it?
text = struct2cell(text)';
Dates = text(:,1);
GAUGE_ts = timeseries(RNFLG,Dates);
SAT_ts = timeseries(SAT_RNFL,Dates);
plot(GAUGE_ts)
hold on
plot(SAT_ts)
ax = gca;
ax.XAxis.TickValues = datetime(Dates);
ax.XAxis.TickLabelFormat = 'M/d';
ax.XAxis.TickLabelRotation = 45;
ax.XAxis.FontSize = 8.5;
dpb
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 ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by