Reputation: 89
With the code below, I get bold y-axis labels but not the x-axis. The issue is the output only when using math_format()
. Curiously, the other aspects like angle
, color
, and size
can be changed, but not the face
of the font.
library(ggplot2)
library(scales)
a <- ggplot(msleep, aes(bodywt, brainwt)) +
geom_point(na.rm = TRUE) +
scale_x_log10(
breaks = trans_breaks("log10", function(x) 10^x),
labels = trans_format("log10", math_format(10^.x)))+
scale_y_log10()+
theme(axis.text.x = element_text(size=10, face="bold", color = "black"),
axis.text.y = element_text(size=10, face="bold", color = "black"))
a
Upvotes: 1
Views: 7161
Reputation: 2977
With direct copy/paste from the function https://stackoverflow.com/a/63674582/10264278 it works!
a <- ggplot(msleep, aes(bodywt, brainwt)) +
geom_point(na.rm = TRUE) +
scale_x_log10(
breaks = trans_breaks("log10", function(x) 10^x),
labels = function(lab) {
do.call(
expression,
lapply(paste(lab), function(x) bquote(bold("10"^.(x))))
)
}) +
scale_y_log10()+
theme(axis.text.x = element_text(size=10, face="bold", color = "black"),
axis.text.y = element_text(size=10, face="bold", color = "black"))
a
Output:
Upvotes: 3