Change color of x axis and y axis barplot
조회 수: 19 (최근 30일)
이전 댓글 표시
I want a barplot with two different y axis in different colors. The x axis should be in black.
Here is my code:
a=[rand(3,1)*100 zeros(3,1) ];
b=[zeros(3,1) rand(3,1)*5 ];
[AX,H1,H2] =plotyy([1:3],a, [1:3],b, 'bar', 'bar');
set(H1,'FaceColor','r') % a
set(H2,'FaceColor','b') % b
set(AX,{'ycolor'},{'r';'b'})
The problem is the x axis whisch should be in black.
I tried
set(AX,{'ycolor'},{'r';'b'}, {'xcolor'}, {'k'})
but the x axis colour did not change.
Does anybody know how to fix this problem?
댓글 수: 0
채택된 답변
Scott MacKenzie
2021년 6월 17일
편집: Scott MacKenzie
2021년 6월 17일
I think this achieves what you are after. Note that plotyy is "not recommended".
a = [rand(3,1)*100, zeros(3,1)];
b = [zeros(3,1), rand(3,1)*5];
yyaxis left;
bar(1:3,a);
yyaxis right;
bar(1:3,b);
댓글 수: 0
추가 답변 (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!