How can I draw two matrices in the same bar graph with same x-axis and y-axis, different colors for each matrix and with no overlapping?

2 次查看(过去 30 天)
Hi, I have two matrices (1x12) q and m as below: q = [0.5 1.2 1.1 0.3 0.2 0.8 0.5 0.7 1.0 1.4 0.6 0.7]; m = [0.2 1.7 1.3 0.1 2.3 4.0 0.9 3.4 1.5 0.5 0.2 3.4]; I draw these matrices with x-axis where x = [1 2 3 4 5 6 7 8 9 10 11 12] by the following code:
plotyy (x,q,x,m,'bar','bar')
I got this gragh..
but I would like to show the graph like this
How can I draw both matrices in the same bar graph with same x-axis and y-axis, with different colors for each matrix and with no overlapping like figure 2 ?
Thanks in advance.

回答(1 个)

dpb
dpb 2016-12-19
bar([m;q].')
for starters; see
doc bar % for details on how to set colors, bar spacing, etc., etc., ...
Per that doc, bar draws separate bar for each column of argument Y

类别

Help CenterFile Exchange 中查找有关 Two y-axis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by