Isabelle Bos
Isabelle Bos

Reputation: 115

ggplot line color "black" becomes red

I used the following script to make the graph below

hypttauplot <- qplot(fuclin_csf, fitHYPTTAU, data=selTAU, geom=c("smooth"),
                     method="glm", color='black', linetype=BL_HYPT) +
               theme_classic() + xlab("Time (years)") + ylab("Tau (pg/ml)") +
               scale_x_continuous(expand=c(0,0)) +
               ggtitle("A. Hypertension") +
               theme(legend.position = "none")

enter image description here

But now my questions is: why are the lines red instead of black? And how can I change them to black?

Upvotes: 3

Views: 4002

Answers (1)

rcs
rcs

Reputation: 68849

You have to use I() to set the aesthetics manually in qplot(), e.g. colour=I("black") (setting vs. mapping of aesthetics).

# mapping
qplot(carat, price, data=diamonds, color="black")
# equivalent to ggplot(data=diamonds, aes(carat, price, color="black")) + geom_point()

plot1

# setting
qplot(carat, price, data=diamonds, color=I("black"))
# equivalent to ggplot(data=diamonds, aes(carat, price), color="black") + geom_point()

plot2

You can use scale_colour_manual to specify an own set of mappings.

Upvotes: 5

Related Questions