Harpal
Harpal

Reputation: 12587

Split up plot axis labels on multiple lines

I have the following graph produced in R:

enter image description here

On the Y axis I have the protein name along with the file name ending in .pdb. How do I make the protein name on one line and the file name on the next line?

I used the following commands to generate the plot:

library(lattice) <br>
data <- read.table("~/Documents/R/test.txt", header=F, sep="\t") <br>
dotplot(V1~V2, xlim=c(0, 2.5), xlab="RMSD Distribution", data=data)

An example input file looks as follows:

Serum Amyloid P Pentamer: 1sac.pdb  0.7125  <br>
Serum Amyloid P Pentamer: 1sac.pdb  0.7917  <br>
Serum Amyloid P Pentamer: 1sac.pdb  0.7819  <br>
Serum Amyloid P Pentamer: 1sac.pdb  0.7762  <br>
Serum Amyloid P Pentamer: 1sac.pdb  1.0233  <br>
Serum Amyloid P Pentamer: 1sac.pdb  0.6896  <br>

The tab between the value and the file is not shown.

Upvotes: 2

Views: 5751

Answers (1)

daroczig
daroczig

Reputation: 28672

Put a \n in the string where you need a line break. In your example just after the colon. E.g.:

data$V1 <- sub(':', ':\n', data$V1)

Upvotes: 7

Related Questions