Why is this plot deleted?

2 ビュー (過去 30 日間)
Cary
Cary 2015 年 10 月 15 日
コメント済み: Star Strider 2015 年 10 月 15 日
As soon as I get to set(gca) the plot disappears. If I continue I get the date formatted tick labels but I don't show any plot. Thanks
plot(matrix(:,1),matrix(:,7));
axis tight
xlabel('Date');
ylabel('PnL');
set(gca,'xtick',linspace(733645,736117,50)); % label 10 ticks using start/end
datetick('x',2,'keepticks'); %convert serial number to date
ax=gca; % get current axis
ax.XTickLabelRotation=45; % rotate ticks 45 degrees

採用された回答

Star Strider
Star Strider 2015 年 10 月 15 日
Apparently, the first set call was the problem. I don’t have your ‘matrix’ variable, but for datetick to work, matrix(:,1) have to be date numbers. After that, combine the set arguments in one call.
This works:
matrix(:,1) = linspace(733645,736117,20);
matrix(:,7) = randn(1,20);
plot(matrix(:,1),matrix(:,7));
axis tight
xlabel('Date');
ylabel('PnL');
datetick('x',2,'keepticks'); %convert serial number to date
set(gca,'xtick',linspace(733645,736117,50), 'XTickLabelRotation',45, 'FontSize',6); % label 10 ticks using start/end
  4 件のコメント
Cary
Cary 2015 年 10 月 15 日
I was on mobile earlier I'm sorry, but I accepted now. Thanks again
Star Strider
Star Strider 2015 年 10 月 15 日
As always, my pleasure. Thank you.

サインインしてコメントする。

その他の回答 (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