How can I use the subscription or superscription in LinkET
Closed this issue · 2 comments
as the title, and i had tried several ways to achieve this.
scale_x_discrete
: not in avail. And there are glaring wrong with the square.ggtext::markdown
: not in avail.linkET::element_formula
: withparse=T
, there is nothing change with the orgin label, that is, remain displayingCO[2]
on the figure.linkET::latex_formula
: not in avail. this function changeCO[2]
toCO *'['*, 2, *']'*
and then just straightfoward display in the figure.
here's the figure with problem, and code attach it. Figure is the result when try the function ggtext::element_markdown
and scale_x_discrete
as description above.
qcorrplot(correlate(na.omit(eda.lon[,3:9])), type = "lower", diag = F)+
geom_square() +
# geom_tile()+
scale_x_discrete(labels = eda.abbr)+
scale_y_discrete(labels = eda.abbr)
geom_couple(aes(colour = pd, size = rd),
data = mantel.mod,
curvature = nice_curvature()) +
# geom_mark(r = NA,size = 3,only_mark = T)+
scale_fill_gradientn(colours = RColorBrewer::brewer.pal(11, "RdBu"),breaks = seq(1, -1, -0.4),limits = c(-1,1)) +
scale_size_manual(values = c(0.5, 1, 2)) +
scale_colour_manual(values = color_pal(3)) +
guides(size = guide_legend(title = "Mantel's r",
override.aes = list(colour = "grey35"),
order = 2),
colour = guide_legend(title = "Mantel's p",
override.aes = list(size = 3),
order = 1),
fill = guide_colorbar(title = "Pearson's r", order = 3))+
theme(
axis.text = element_markdown(color = "black",size = 10))
Instead of manually adding scale_x/y_*()
to the qcorrplot()
function, we can set parse = TRUE
in qcorrplot()
to handle the subscript/superscripts of axis labels, as shown in the following example:
library(linkET)
d <- mtcars
names(d) <- c("NH^4", names(d)[-1L])
correlate(d) |>
qcorrplot(parse = TRUE) +
geom_square()
Note that linkET
uses a style similar to LaTex to distinguish between superscripts and subscripts, for example:
x <- "label^{this is superscript}_{this is subscript}"
Thank you so much! your answer perfectly solve my problem and I believe your answer will also benefit many people who encounter the same error like me, due to I have read various articles about "how to present special sympols like superscription" with this package. However, none of those solutions actually work. Overall, I really appreciate your reply! And I will close this issue later.
Instead of manually adding
scale_x/y_*()
to theqcorrplot()
function, we can setparse = TRUE
inqcorrplot()
to handle the subscript/superscripts of axis labels, as shown in the following example:library(linkET) d <- mtcars names(d) <- c("NH^4", names(d)[-1L]) correlate(d) |> qcorrplot(parse = TRUE) + geom_square()Note that
linkET
uses a style similar to LaTex to distinguish between superscripts and subscripts, for example:x <- "label^{this is superscript}_{this is subscript}"