Problem with overlapping bars in a plot with 2 y axis.
조회 수: 2 (최근 30일)
이전 댓글 표시
I am trying to plot a bar chart with 2 y-axes in MATLAB. The 2-axes feature works, however, the bars are overlapping. Also, the categories on the right-hand axis should have different colors, not the same red. How can this be done? Also, how can I label both y axes? Here is the code I am using:
C1=[0.9;0.89;0.65;0.05;0.01;0.01]
C2=[7.76 9.42;7.7 9.14;8.4 6.3;8.5 6;9.6 7.1;9.5 7.15]
yyaxis left
bar(C1)
ylim([0 1.1])
yyaxis right
bar(C2);
ylim([0 12])
set(gca,'XTickLabel',{'0.013 g','0.13 g','0.27 g','0.67 g','1.30 g','2.7 g'},'FontWeight','bold')
legend('Nitrate removal','pH','DO','FontWeight','bold')
ylabel('pH/DO','FontWeight','bold')
xlabel('Amount of NPs (g)','FontWeight','bold')
댓글 수: 0
답변 (1개)
dpb
2019년 5월 26일
Answers/325849 bar graph with two yaxes Illustrates how to solve this...it's a pain TMW hasn't built a routine for such already; it's an obvious shortcoming.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Bar Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!