Bar charts with categories in the x axis

4 次查看(过去 30 天)
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 个评论
Star Strider
Star Strider 2014-10-29
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.

请先登录,再进行评论。

回答(1 个)

Orion
Orion 2014-10-29
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');

类别

Help CenterFile Exchange 中查找有关 Bar Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by