Marc, you are kind of crazy ... I asked for a discussion of the path to take to get there, not to have it done ... but hey, what am I complaining about? ;0)
Thank you very much! Joh Marc Schwartz wrote: > Johannes Graumann wrote: >> I really do not know ho to else title this ... I want to draw something >> like the attached png with R and would like to poll you on how to start >> ... make an empty plot first and then start positioning the >> characterstring by 'text' and then drawing the lines ... >> >> Joh > > Johannes, > > Try this (PDF of the output attached): > > # Open the initial plot window and set > # up a coordinate system based upon > # placement of the letters centered > # on integer 'x' values 1:12 > plot(1, xlim = c(0, 13), ylim = c(0, 4), > type = "n", > ann = FALSE, axes = FALSE) > > # Create the vector of letters > Vec <- c("T", "V", "F", "S", "Q", "A", "Q", > "L", "C", "A", "L", "K") > > # Plot them > text(1:12, 2, Vec, cex = 2, font = 2) > > # Get the height of the letters for spacing > # See ?strheight > height <- strheight("T", cex = 2) * .8 > > # Set a default width for the "boxes" > # around the letter > width <- 0.5 > > # Set the values for 'Y's > Y <- 10:2 > X <- 3:11 > > # Loop over the Y's and using plotmath > # plot the values and subscripts in bold > # See ?plotmath and ?bquote > # While looping, do the colored segments > for (i in 1:9) { > text(X[i], 2 + (height * 1.6), bquote(bold(Y[.(Y[i])])), > col = "red", font = 2) > > x <- c(X[i] - width, X[i] - width, X[i] + 0.3) > y <- c(2, 2 + height, 2 + height) > > lines(x, y, col = "red", lwd = 2) > } > > > > > # Same here now for the 'b's > > b <- c(2:6, 8, 9, 11) > X <- b > > for (i in 1:8) { > text(X[i], 2 - (height * 1.6), bquote(bold(b[.(b[i])])), > col = "blue", font = 2) > > x <- c(X[i] - 0.3, X[i] + width, X[i] + width) > y <- c(2 - height, 2 - height, 2) > > lines(x, y, col = "blue", lwd = 2) > } > > > > The above should provide the basic approach. You can then adjust/fine > tune spacing, etc. as you require. > > HTH, > > Marc Schwartz ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.