I am plotting two arrays in one plot. The bar plot must show two y-axis as well as the bars next to each other. The problem occurs when I want to implement both requirements.
I can either plot the bars together with for example
Y = [5,2; 8,7; 9,8; 5,5; 4,3];
figure
bar(Y)
Or I can create two y-axis (which I do currently with my data):
y = [lr_flights2018, lr_income2018];
yyaxis left
b = bar(1:length(y),lr_flights2018);
ylabel('Life Rating/flights ratio')
yyaxis right
p = bar(1:length(y),lr_income2018);
ylabel('Life Rating/income ratio')
set(gca, 'XTick', 1:length(y))
set(gca,'XTickLabel',{countries{:,1}})
xtickangle(90)
title('Correlations with life rating');
In the latter yyaxis separates the plots which results in the two plots stacked together. I want the plots to stand side by side for each bin as can be seen in
this example.
