2017-01-25 5 views
0

ich ein Grundstück in MATLAB mit folgenden Eigenschaften erstellen möchten:Wie plotten Strings in Matlab

  • Auf der x-Achse I 4 verschiedenen Saiten haben wollen: ['string1','string2','string3','string4']
  • Ich möchte, dass jeder von ihnen Zeichenketten, die 2 Teilzeichenfolgen haben: ['sub1','sub2'] aber ich möchte, dass sie über den Hauptsaiten angezeigt werden, was sie zu einer 'sur-Zeichenkette' machen würde? Ich hoffe du weißt was ich meine.
  • Dann auf der Y-Achse, möchte ich 3 verschiedene Arten von Daten für jede Unterzeichenfolge darstellen.

Ich dachte, vielleicht ist es möglich, dies mit einem Stamm-Plot zu realisieren. Ich hätte dann 3 Stiele bei jeder Sub-Saite. Das macht 6 bei jeder Saite. Welches Diagramm passt am besten dazu?

Antwort

1

Sie können den text Befehl, um die Saiten auf der x-Achse erhalten

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

Um Grundstück von der y stammt Achse Sie den Plotrahmens mit view Befehlen wie diesen drehen könnte:

% 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