2017-01-25 4 views
0

Я хочу, чтобы создать участок в MATLAB со следующими характеристиками:Как построить строки в Matlab

  • На оси х я хочу иметь 4 различных строк: ['string1','string2','string3','string4']
  • Я хочу, чтобы каждый из них строки должны иметь 2 подстроки: ['sub1','sub2'] , но я хочу, чтобы они отображались над основными строками, что сделало бы их «суровой струной»? Надеюсь, ты знаешь, что я имею в виду.
  • Затем по оси y я хочу построить 3 разных типа данных для каждой подстроки.

Я понял, может быть, это возможно реализовать с помощью штопора. У меня тогда было бы 3 стебля в каждой подстроке. Это составляет 6 в каждой строке. Какая диаграмма лучше всего подходит для этого?

ответ

1

Вы можете использовать команду text, чтобы получить строки на оси х

stem(rand(4,1)); 
set(gca, 'XTick', [1:4], 'XTickLabel', cell(10,1), 'YLim', [0 1]); 
text(1, -.05, {'above string 1', 'above string 1', 'string 1'}, 'FontSize', 10, 'HorizontalAlignment', 'Center'); 
text(2, -.05, {'above string 2', 'above string 2', 'string 2'}, 'FontSize', 10, 'HorizontalAlignment', 'Center'); 
text(3, -.05, {'above string 3', 'above string 3', 'string 3'}, 'FontSize', 10, 'HorizontalAlignment', 'Center'); 
text(4, -.05, {'above string 4', 'above string 4', 'string 4'}, 'FontSize', 10, 'HorizontalAlignment', 'Center'); 

stem plot

Для участка вытекающей из оси Y можно вращать участок кадра, используя view команду:

% plot some data 
stem([1:3], 'LineWidth', 2); 

% set the x axis which will be the y axis after the rotation 
set(gca, 'XLim', [1 3], 'XTick', [1:3], 'XTickLabel', cell(3,1)); 
text(1.1, -.25, {'another y string 1', 'above y string 1', 'y string 1'}, 'FontSize', 10, 'HorizontalAlignment', 'Center'); 
text(2, -.25, {'another y string 2', 'above y string 2', 'y string 2'}, 'FontSize', 10, 'HorizontalAlignment', 'Center'); 
text(3, -.25, {'another y string 3', 'above y string 3', 'y string 3'}, 'FontSize', 10, 'HorizontalAlignment', 'Center'); 

% set the y axis which will be the x axis after the rotation 
set(gca, 'YLim', [0 3], 'YTick', [1:4], 'YTickLabel', cell(10,1)); 
text(0.9, 0, {'above string 1', 'above string 1', 'string 1'}, 'FontSize', 10, 'HorizontalAlignment', 'Center'); 
text(0.9, 1, {'above string 2', 'above string 2', 'string 2'}, 'FontSize', 10, 'HorizontalAlignment', 'Center'); 
text(0.9, 2, {'above string 3', 'above string 3', 'string 3'}, 'FontSize', 10, 'HorizontalAlignment', 'Center'); 
text(0.9, 3, {'above string 4', 'above string 4', 'string 4'}, 'FontSize', 10, 'HorizontalAlignment', 'Center'); 

% rotate the view 
view(90,-90) 

rotated stems