2017-09-05 137 views
0

我試圖在MATLAB分組的情節吧,作爲一個你可以在這個例子中看到:分組條形圖Matlab的

Grouped Plot Bar example

你知道它如何進行?這是我迄今爲止所做的,並且它不能按我的要求工作。

y = [Cerrillos; Talagante]; 
bar(y) 

title('Concentraciones 2015-2016') 
xlabel('Estaciones') 
ylabel('µg/m³') 
+0

y是數值數據與對應於對應於各個列組和列的行,即12X2矩陣會給你12組的每個2個酒吧。請參閱內置幫助中的欄幫助頁面。 – Gryphon

+1

可能的重複:[分組在matlab中的酒吧](https://stackoverflow.com/q/37527474/52738) – gnovice

回答

0

這裏是分組條碼:

y = [7 7; 21 15]; 
fig=figure(); 
a=bar(y) 
XTickLabel={'Cerrillos' ; 'Talagante'}; 
XTick=[1 2] 
set(gca, 'XTick',XTick); 
set(gca, 'XTickLabel', XTickLabel); 
set(gca, 'XTickLabelRotation', 45); 
legend('2015','2016') 

title('Concentraciones 2015-2016') 
xlabel('Estaciones') 
ylabel('µg/m³') 

enter image description here

+0

它的作品完美!非常感謝!!!! – Rulo