"Maja Schröter"
2007-Jul-15 15:58 UTC
[R] Text with differents colors in a plot / Detecting if text exists
Hi everybody, I want to write some text in a plot. That's simple I know. But I want to make use of different colors. Eg. text(x,y,paste("Sunderland","high")). Then Sunderland should be black and "high" red. Has anyone an idea? By the way. I'm looking for a function or something similar, that can check whether there is text in some regions on the plot. Because I don't want to overwrite an existing text with a new one. Thank you so much for your help. I appologize in advance if my question is very stupid but I have really no idea. Yours, Maja --
Jim Lemon
2007-Jul-16 10:01 UTC
[R] Text with differents colors in a plot / Detecting if text exists
Maja Schr?ter wrote:> Hi everybody, > > I want to write some text in a plot. > > That's simple I know. But I want to make use of different colors. > > Eg. text(x,y,paste("Sunderland","high")). > > Then Sunderland should be black and "high" red. > > Has anyone an idea? > > By the way. I'm looking for a function or something similar, that can check whether there is text in some regions on the plot. > Because I don't want to overwrite an existing text with a new one. >Hi Maja, For your first question: text(c(9,9),c(5,5),c("Sunderland","high"), pos=c(2,4),offset=0.2,col=c("black","red")) i.e., don't form a single string so that you can specify different colors and positions for the two words. For the second one, I am about to upload a new version of the plotrix package that contains a function named "emptyspace". This tries to find the largest rectangle on a plot that has nothing plotted within it. Jim
Possibly Parallel Threads
- Highliting a text in a plot
- Dividing objects in classes using function sample()
- Functions for autoregressive Regressionmodels (Mix between times series and Regression Models) ?
- Problems using "lm" in combination with "predict"
- Problems with Vista, R 2.5.0 and function save