How can I create a plot with column headings along the X-axis?

11 次查看(过去 30 天)
Hi I need to plot a matrix such that every column heading is listed along the x-axis and every cell in that column is plotted along the Y-axis? I have attached a picture of the same. I am a newbie to MATLAB. Could someone please help? Thanks in advance Deepa

采纳的回答

Star Strider
Star Strider 2017-7-5
Try this:
M = randi(9, 3); % Create Matrix
x = 1:size(M,2); % Column numbers
labelstr = sprintf('Column %d\n', x); % Create Labels
labelcel = regexp(labelstr, '\n', 'split'); % Split & Create Cell Array
figure(1)
plot(x, M', '.b', 'MarkerSize',20)
set(gca, 'XTickLabel',[])
set(gca, 'XTick',x, 'XTickLabel',labelcel(1:end-1), 'XTickLabelRotation',90)
axis([0 4 0 10])
  4 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by