bar chart with different width

조회 수: 2 (최근 30일)
Tiago Dias
Tiago Dias 2019년 6월 12일
Hi,
I got a problem with my bar charts, some bar got a different width then others, for the cyan and mangent bars. I attach a picture so you can see. Green and blue bars are ok, bue cyan and purple for some reason are larger, and I dont know why.
_order is the index which i want to paint with a specific color.
load('Parameter.mat')
[IG_order, IG_index_order] = sort(Parameter,'descend');
Reaction_order = arrayfun(@(x) find(IG_index_order==x,1),Reaction)
Pressure_order = arrayfun(@(x) find(IG_index_order==x,1),Pressure)
Separation_order = arrayfun(@(x) find(IG_index_order==x,1),Separation)
Hydrogen_order = arrayfun(@(x) find(IG_index_order==x,1),Hydrogen)
Feed_order = arrayfun(@(x) find(IG_index_order==x,1),Feed)
FuelGas_order = arrayfun(@(x) find(IG_index_order==x,1),FuelGas)
Other_order = arrayfun(@(x) find(IG_index_order==x,1),Other)
out = figure();
set(out,'PaperUnits','centimeters','PaperPosition',[0 0 29 21], 'PaperOrientation','landscape');
h_bar11 = bar(Reaction_order,IG_order(Reaction_order),'b'); hold on
h_bar22 = bar(Pressure_order,IG_order(Pressure_order),'g'); hold on
h_bar33 = bar(Separation_order,IG_order(Separation_order),'r'); hold on
h_bar44 = bar(Hydrogen_order,IG_order(Hydrogen_order),'m'); hold on
h_bar55 = bar(Feed_order,IG_order(Feed_order),'c'); hold on
h_bar66 = bar(FuelGas_order,IG_order(FuelGas_order),'y'); hold on
h_bar77 = bar(Other_order,IG_order(Other_order),'k'); hold off
legend('Reactor','Pressure','Separation','Hydrogen','Feed','Fuel Gas','Other','Location','northeast')
xlim([0 size(Parameter,1)+1]) % esthetics -> To get an extra space in the plot for the last variable (+1)
var_list2 = sprintfc('X%d', IG_index_order);
set(gca, 'XTickLabel', var_list2);
xticks(1:1:size(Parameter,1));
xtickangle(90);
yticks(0:5:100);
xlabel('Variables','FontWeight','bold')
ylabel('Global Importance (%)','FontWeight','bold')
title('R2-Normalized')
grid on
ax = gca; ax.XAxis.LineWidth = 1.5; ax.YAxis.LineWidth = 1.5;

답변 (0개)

카테고리

Help CenterFile Exchange에서 Bar Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by