Bar charts with categories in the x axis

4 vues (au cours des 30 derniers jours)
Bill
Bill le 29 Oct 2014
Commenté : Star Strider le 29 Oct 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 commentaire
Star Strider
Star Strider le 29 Oct 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.

Connectez-vous pour commenter.

Réponses (1)

Orion
Orion le 29 Oct 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