# How do you make a label for a point on a plot separate into multiple lines?

6 Ansichten (letzte 30 Tage)
Brianna Miranda am 12 Okt. 2022
Beantwortet: Star Strider am 12 Okt. 2022
Please do not send the matlab help page for text as an answer, I have reviewed that form and it does not address the question I am asking. I have a figure I am plotting that has one point on the plot labeled. The label is one line but I want to separate the label into two lines. The code I am using is below.
txt = ['f=' num2str(f_Trim(indMaxAmp(ii))) 'Hz','P1=' num2str(maxAmp(ii)) 'dB'];
xname = f_Trim(indMaxAmp(end));
yname = maxAmp(end);
text(xname,yname,txt,'HorizontalAlignment','left')
I have also tried using txt = {'f=' num2str(f_Trim(indMaxAmp(ii))) 'Hz','P1=' num2str(maxAmp(ii)) 'dB'};
but this plots each value on a different lines, so a total of 6 lines.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Star Strider am 12 Okt. 2022
ii = 1;
indMaxAmp(ii) = 24;
maxAmp(ii) = 42;
txt = sprintf('f = %.3f Hz\nP1 = %.3f dB', indMaxAmp(ii), maxAmp(ii));
figure
xname = 0.3;yname = 0.7;
text(xname,yname,txt,'HorizontalAlignment','left')
.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Axis Labels finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by