![]() ![]() Here is an example that creates a figure with a 2 x 2 subplot grid, populates each subplot with a scatter trace, and then updates the x and y axis titles for each subplot individually. The row and col arguments can be used to control which axes are targeted by the update. By default, these methods apply to all of the x axes or y axes in the figure. Customizing Subplot AxesĪfter a figure with subplots is created using the subplot function, its axis properties (title, font, range, grid style, etc.) can be customized using the xaxis and yaxis graph object figure methods. Library ( dash ) library ( dashCoreComponents ) library ( dashHtmlComponents ) library ( plotly ) app <- Dash $ new () app $ layout ( htmlDiv ( list ( dccGraph ( id = 'graph-with-slider' ), htmlLabel ( 'Subplots Width:' ), dccSlider ( id = 'slider', min = 0, max = 1, value = 0.5, step = 0.01 ) ) ) ) app $ callback ( output ( id = 'graph-with-slider', property = 'figure' ), params = list ( input ( id = 'slider', property = 'value' )), function ( value ) )Īfter executing this code, give app$run_server() in the console to start the dash. It would not be possible to scroll or pan or zoom the images individually, and you would need extra work to data cursor them individually.Library ( plotly ) fig1 % layout ( title = 'Multiple Subplots with Titles', plot_bgcolor = '#e5ecf6', xaxis = list ( zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff' ), yaxis = list ( zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff' )) annotations = list ( list ( x = 0.2, y = 1.0, text = "Plot 1", xref = "paper", yref = "paper", xanchor = "center", yanchor = "bottom", showarrow = FALSE ), list ( x = 0.8, y = 1, text = "Plot 2", xref = "paper", yref = "paper", xanchor = "center", yanchor = "bottom", showarrow = FALSE ), list ( x = 0.2, y = 0.45, text = "Plot 3", xref = "paper", yref = "paper", xanchor = "center", yanchor = "bottom", showarrow = FALSE ), list ( x = 0.8, y = 0.45, text = "Plot 4", xref = "paper", yref = "paper", xanchor = "center", yanchor = "bottom", showarrow = FALSE )) fig % layout ( annotations = annotations ) #options(warn = -1) fig
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |