Question

I have been working with this for some time and can't find any reasonable explanation for why the names of my x and y axis are the correct color, but not the title.

p <- ggplot(movies, aes(x=budget, y=rating))+
  geom_point(shape=1) +
  theme(axis.title.x = element_text(colour = "#7F3D17"),
        axis.title.y = element_text(colour = "#7F3D17"),
        axis.title = element_text(colour = "#7F3D17"),
        panel.background = element_rect(fill='#FFD197'),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.border = element_blank()) +
  labs(x="Budget (in millions)", y="Rating", title="Scatterplot of budget vs movies")
p

The scatterplot looks like this (notice that the title is still black):

enter image description here

If anyone could help I would greatly appreciate it.

Was it helpful?

Solution

You are using axis.title = element_text(colour = "#7F3D17") to get the right color for the title. But you should be using plot.title = element_text(colour = "#7F3D17").

With axis.title you define the setting for both axis, whereas with axis.title.x or axis.title.y you define the setting for the x-axis title or y-axis title specifically.

Because you are using the same color for all the titles, you can also use title = element_text(colour = "#7F3D17") which should set the color of the plot title, axis titles and legend title to the same color.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top