Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split the Main title of a plot in 2 or more lines?

Tags:

r

Is it possible to split the main title of a plot() in 2 or more lines in R?

Moreover I have a title which consists of many argumenets pasted together

plot(1, main=paste("X:",1," ","Y:", 2," ","Z:",3)) 

How can I insert a line break between Y and Z in the main?

Thanks E.C

like image 349
ECII Avatar asked Nov 13 '11 16:11

ECII


People also ask

How do I add a new line to a title in Matlab?

When displaying text on plots, "\n" is typically interpreted as '\' followed by 'n' instead of the newline character. To generate multiple lines, use cell arrays. This is done by separating each string line of text with a comma and enclosing all comma-separated strings in curly braces as follows.

How do you add title on the plot?

Click the chart, and then click the Chart Design tab. Click Add Chart Element > Axis Titles, and then choose an axis title option. Type the text in the Axis Title box. To format the title, select the text in the title box, and then on the Home tab, under Font, select the formatting that you want.


2 Answers

Like this:

plot(1) title(main="This is \nTitle") 

Edit:

Try this

plot(1, main=paste("X:",1," ","Y:", 2," ","\nZ:",3)) 
like image 100
jrara Avatar answered Sep 30 '22 17:09

jrara


plot(1, main=paste("X:",1," ","Y:", 2," ","\nZ:",3)) 
like image 25
vaettchen Avatar answered Sep 30 '22 17:09

vaettchen