I am wondering how to give difference subtitles for the subplots using plot_ly. Any hint please. I got one title BB in this case. Thanks.
p <- subplot( plot_ly(economics, x = date, y = uempmed)%>%layout(showlegend = FALSE, title="AA"), plot_ly(economics, x = date, y = unemploy)%>%layout(showlegend = FALSE, title="BB"), margin = 0.05 )
Plotly is a free and open-source graphing library for R. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.
The subplot() function Conceptually, subplot() provides a way to place a collection of plots into a table with a given number of rows and columns. The number of rows (and, by consequence, the number of columns) is specified via the nrows argument.
top - layout. margin. bottom. In such a rectangle you set the width and height of each subplot, in pixels.
Simple SubplotFigures with subplots are created using the make_subplots function from the plotly. subplots module. Here is an example of creating a figure that includes two scatter traces which are side-by-side since there are 2 columns and 1 row in the subplot layout.
The title
attribute in layout refers to the title for the entire plotting surface, so there can only be one. However, we can use text annotations to create "titles" for your subplots, for example:
p <- subplot( plot_ly(economics, x = date, y = uempmed)%>%layout(showlegend = FALSE), plot_ly(economics, x = date, y = unemploy)%>%layout(showlegend = FALSE), margin = 0.05 ) p %>% layout(annotations = list( list(x = 0.2 , y = 1.05, text = "AA", showarrow = F, xref='paper', yref='paper'), list(x = 0.8 , y = 1.05, text = "BB", showarrow = F, xref='paper', yref='paper')) )
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