Library ( plotly ) data ( iris ) fig % group_by ( Species ) %>% do ( p = plot_ly (. , x = ~ Sepal.Width, y = ~ Sepal.Length, type = "scatter", opacity = 0.5, mode = "markers", marker = list ( color = "blue" ))) %>% subplot ( nrows = 1, shareX = TRUE, shareY = TRUE ) fig % layout ( annotations = list ( list ( x = 0.16, y = 1, font = list ( size = 10 ), text = "species=setosa", xref = "paper", yref = "paper", xanchor = "center", yanchor = "bottom", showarrow = FALSE ), list ( x = 0.5, y = 1, font = list ( size = 10 ), text = "species=versicolor", xref = "paper", yref = "paper", xanchor = "center", yanchor = "bottom", showarrow = FALSE ), list ( x = 0.85, y = 1, font = list ( size = 10 ), text = "species=virginica", xref = "paper", yref = "paper", xanchor = "center", yanchor = "bottom", showarrow = FALSE ))) %>% layout ( plot_bgcolor = '#e5ecf6', xaxis = list ( title = list ( text = 'Sepal.Width', font = list ( size = 15, family = 'Courier', color = 'crimson' )), zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff' ), xaxis2 = list ( title = list ( text = 'Sepal.Width', font = list ( size = 15, family = 'Courier', color = 'crimson' )), zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff' ), xaxis3 = list ( title = list ( text = 'Sepal.Width', font = list ( size = 15, family = 'Courier', color = 'crimson' )), zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff' ), yaxis = list ( title = list ( text = 'Sepal.Length', font = list ( size = 18, family = 'Courier', color = 'crimson' )), zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff' ), showlegend = F ) fig In the example below the automatic X axis type would be linear (because there are not more than twice as many unique strings as unique numbers) but we force it to be category. It is possible to force the axis type by setting explicitly autotypenumber.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |