Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Create Bar Charts with different bar colours with a legend

2 Ansichten (letzte 30 Tage)
BdS
BdS am 27 Mär. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hi,
I would like to create a bar chart (not stacked) with different colour for each bar. But it should also include a legend (in the top right of the bar chart) with the names for each coloured bar (=the variable names). Thank you for your help.
% here is my code
for f=1:nBEKBFonds
figure(f)
pInd=transpose(peersInd==f);
% choose corresponding funds for each strategie
Var1=TotRetBEKB(1,f);
Var2=TotRetPeers(1,pInd);
VarPlot=[Var1,Var2];
% plot
bar(VarPlot);
grid on
.
.
end

Antworten (1)

Cris LaPierre
Cris LaPierre am 28 Mär. 2020
This is a popular assignment today. See this post.
As for the legend, it's pretty simple. Take a look at this doc page for how to do it.

Community Treasure Hunt

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

Start Hunting!

Translated by