Search code examples
plotoctaveaxis-labels

Changing font size on one line in multiline plot label in Octave


Is it possible to change the font size of one line of text in a multiline plot label using the ylabel command. If so how?

PS: I'm using Octave 5.2

I tried the code below but it gives me an error.

figure
plot((1:10).^2)
ylabel_txt1=strcat('1st line of text with smaller font') %1st line
ylabel_txt2=strcat('2nd line of text') %2nd line
ylabel({(ylabel_txt1,'fontsize',13) ;ylabel_txt2})

Solution

  • ylabel uses the tex interpreter by default, and tex interpreter allows changing the font size at arbitrary locations in the text using \fontsize{size}.

    This is what you should be doing:

    ylabel({['\fontsize{13}', ylabel_txt1]; ['\fontsize{10}', ylabel_txt2]})
    

    For other formatting options, you can take a look at the 'Text Properties' page in documentation.