Bar charts with categories in the x axis

4 Ansichten (letzte 30 Tage)
Bill
Bill am 29 Okt. 2014
Kommentiert: Star Strider am 29 Okt. 2014
Hi, I have data such as:
Product 1 a 15, Product 1 b 25, Product 2 a 23, Product 2 b 12, Product 2 b 6 , Product 3 a -23, Product 3 b 2,
and I want to plot a bar chart where the y axis would be the numbers and the x axis the letters where they are grouped according to their product number, how can I do this with matlab because I am struggling with the bar plotting function. Thanks.
  1 Kommentar
Star Strider
Star Strider am 29 Okt. 2014
What version of MATLAB are you using? Are you using a grouped bar chart? Barseries properties that were accessible before R2014b are no longer accessible in HG2.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Orion
Orion am 29 Okt. 2014
Hi,
I'm not sure I get your problem, but I think you want something like :
% plot the data as bar
value = [15,25,23,12,-23,2];
bar(value);
ylabel('Quantity');
% change the xticklabel with characters
newXticklabel = {'1a','1b','2a','2b','3a','3b'};
set(gca,'XtickLabel',newXticklabel);
xlabel('Product');

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by