how to change the order of plots?

16 ビュー (過去 30 日間)
Chang seok Ma
Chang seok Ma 2021 年 12 月 5 日
編集済み: Adam Danz 2021 年 12 月 6 日
Hello,
I have a following code
figure(3)
colororder({'b','r'})
yyaxis left
bar(horizon2,data2(:,2),1,'FaceColor',[1 1 1],'EdgeColor','b','LineWidth',2)
hold on
bar(horizon3,data3(:,2),1,'FaceColor',[1 1 1],'EdgeColor','g','LineWidth',2)
hold on
%,'FaceAlpha',0.6
xlabel('Thousands of dollars')
% 2007m12
grid on
yyaxis right
bar(horizon1,data1(:,4),1,'FaceColor',[1 1 1],'EdgeColor','r','LineWidth',2)
then I have a graph as follows
But I want to have green plots over red and blue plots.
Is there anyway I could do this?
Thank you

採用された回答

Adam Danz
Adam Danz 2021 年 12 月 5 日
編集済み: Adam Danz 2021 年 12 月 6 日
As of the current Matlab release (R2021b), it is not possible to control the uistack of objects on different sides of a yyaxis. Objects assigned to the right axis will always be on top.
Alternative work-arounds
  • Move the red bars to the left y-axis and the green/blue bars to the right axis.
  • Use plotyy instead (but yyaxis is still much better). See this answer.
  • Use transparency to see overlapping bars. See FaceAlpha and EdgeAlpha properties of bar objects.

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