Skip to content
Back to formatted view

Raw Message

Message-ID: <d8ad40b50901211537i7d7d346w740842147113f7f6@mail.gmail.com>
Date: 2009-01-21T23:37:23Z
From: Barry Rowlingson
Subject: title: words in different colors?
In-Reply-To: <4977AADB.2080700@yorku.ca>

2009/1/21 Michael Friendly <friendly at yorku.ca>:
> In ?title I see the
>
> plot(cars, main = "")
> title(main = list("Stopping Distance versus Speed", cex=1.5, col="red",
> font=3))
>
> I can't seem to generalize this to use several colors in a single title.

 Solution from http://tolstoy.newcastle.edu.au/R/e2/help/07/09/24599.html
adapted for title:

  plot(1:10)
  title(expression("hair Color" * phantom(" and Eye color")),col.main="red")
  title(expression(phantom("hair Color and ") * "Eye color"),col.main="blue")
  title(expression(phantom("hair Color ") * "and" * phantom("Eye
color"),col.main="black"))

 The trick is to overlay three titles, one for each colour, with the
stuff not in that colour wrapped in a phantom() call to produce the
correct spacing in invisible ink.

  There's probably other ways...

Barry