Azzera filtri
Azzera filtri

bar chart with different width

4 visualizzazioni (ultimi 30 giorni)
Tiago Dias
Tiago Dias il 12 Giu 2019
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.
[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);
ylabel('Global Importance (%)','FontWeight','bold')
grid on
ax = gca; ax.XAxis.LineWidth = 1.5; ax.YAxis.LineWidth = 1.5;

Risposte (0)


Community Treasure Hunt

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

Start Hunting!

Translated by