Bar charts with categories in the x axis

4 visualizaciones (últimos 30 días)
Bill
Bill el 29 de Oct. de 2014
Comentada: Star Strider el 29 de Oct. de 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 comentario
Star Strider
Star Strider el 29 de Oct. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Orion
Orion el 29 de Oct. de 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');

Categorías

Más información sobre Bar Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by