Reputation: 478
I am not sure why the caption is not changing, I might be using the wrong functions. Here is an example:
My dataframe moment.curve
:
moment.curv <- structure(list(row = 1:5, Curvature = c(
0, 0.001805, 0.004512,
0.008121, 0.0126
), Moment = c(
0, 192.0442, 242.8942, 256.6455,
258.1099
)), class = "data.frame", row.names = c(NA, -5L))
I use the following code to create the plot:
plot.moment.curv <- ggplot(moment.curv) +
aes(x = Curvature, y = Moment) +
geom_line(size = 1L, colour = "#0c4c8a") +
labs(x = "bla", y = "bla") + theme_classic()
I use the following to create a ggplotly interactive plot, keep in mind I want to keep this format that I make the original plot in ggplot and then convert it to an interactive plot with ggplotly. The actual figures I am creating are much more complicated and this makes the process easier.
ggplotly(
p = ggplot2::last_plot(),
width = NULL,
height = NULL,
tooltip = "all",
dynamicTicks = FALSE,
layerData = 1,
originalData = TRUE,
) %>%
layout(margin = list(b=130,t=100), annotations =
list(x = 1, y = -0.4, text = "THE CAPTION",
showarrow = F, xref='paper', yref='paper',
xanchor='right', yanchor='auto', xshift=0, yshift=0,
font=list(size=15,fontfacet="italic"))
)
Thank you!
Upvotes: 1
Views: 1028
Reputation: 123988
To change the font face you have to use HTML tags, i.e. to italicize your caption use text = "<i>THE CAPTION</i>"
.
Upvotes: 2