Skip to content

Legends text

3 messages · Sebastien Durand, Marc Schwartz, Uwe Ligges

#
Hi,

Is there a way to change the color of the text inside a legend, let 
say I would like to use a black background in my legend, how can I 
get the text to show up, it is black!!!
So for example how could I change it to white...?

Sebastien
#
On Tue, 2004-02-24 at 10:45, Sebastien Durand wrote:
legend() does not support an argument to change the text color, so you
have to change the plot parameters prior to calling legend():

# Draw a quick plot
plot(1:5)

# Save the old text color value
col.old <- par("col")

# Set the text color to white
par("col" = "white")

# Draw the legend
legend(1, 5, legend = "Text Goes Here", bg = "black")

# Restore the original text color
par("col" = col.old)


HTH,

Marc Schwartz
#
Sebastien Durand wrote:

            
By setting par(fg = "white"):

  plot(1:10)
  par(fg="white")
  legend(2,2, col="white", legend="A", bg="black")

Uwe Ligges