I've been trying to use ggplot2 and the ggplotly function from the "plotly" library in R to make a faceted grid with italicized labels on y-axis and just can't seem to make it to happen.
Here I'll use the "Free Y Axis" example of a faceted grid as written by Plotly: https://plotly.com/ggplot2/facet_grid/
The only change I've made to this code is make the strip text for both axes larger and the y-axis text italicized in the ggplot theme().
library(reshape2)
library(ggplot2)
library(plotly)
p <- ggplot(tips, aes(x=total_bill)) + geom_histogram(binwidth=2,colour="white")
# With panels that have the same scaling, but different range (and therefore different physical sizes)
p <- p + facet_grid(sex ~ smoker, scales="free", space="free") +
theme(strip.text.x=element_text(size=13),
strip.text.y=element_text(size=13,face="italic"))
p
fig <- ggplotly(p)
fig
The plot produced by ggplot (p) looks like this, with the y-axis facet labels in italics: ggplot with proper italicization
The plot produced by ggplotly (fig) looks like this: ggplotly with no italicization
You could modify the data in p
, adding html tags for italics
library(reshape2)
library(ggplot2)
library(plotly)
p <- ggplot(tips, aes(x=total_bill)) + geom_histogram(binwidth=2,colour="white")
p <- p + facet_grid(sex ~ smoker, scales="free", space="free") +
theme(strip.text.x=element_text(size=13),
strip.text.y=element_text(size=13, face="italic"))
p$data$sex <- paste0("<i>", p$data$sex, "</i>")
fig <- ggplotly(p)
fig
Created on 2020-07-08 by the reprex package (v0.3.0)