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):
If anyone could help I would greatly appreciate it.
Change colors manually A custom color palettes can be specified using the functions : scale_fill_manual() for box plot, bar plot, violin plot, etc. scale_color_manual() for lines and points.
We can change the appearance text elements of a plot made with ggplot2 using theme element element_text() function. To make both x and y-axis's title text in bold font, we will use axis. title argument to theme() function with element_text(face=”bold”). Note now both x and y axis's title text are in bold font.
Default ggplot gradient colorsThe default ggplot2 setting for gradient colors is a continuous blue color. In the following example, we color points according to the variable: Sepal. Length . sp2 <- ggplot(iris, aes(Sepal.Length, Sepal.Width))+ geom_point(aes(color = Sepal.Length))
To set labels for X and Y axes in R plot, call plot() function and along with the data to be plot, pass required string values for the X and Y axes labels to the “xlab” and “ylab” parameters respectively. By default X-axis label is set to “x”, and Y-axis label is set to “y”.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With