Titles and Legends
Deephaven Plotly Express provides ways to customize titles and legends with intuitive default behavior.
Default Title
The names of the x and y axes are set to the column names when passing single column names in.
Plot by Titles and Legend
When using the by argument, the legend is automatically generated.
An entry is created for each unique value in the by column.
Titles and Legend for Multiple Columns
When passing in a list of columns, the axis title for the corresponding axis is set to a new name, value.
As with the by argument, the legend is automatically generated.
Title Customization
Custom Title
Add a title to the plot with the title argument.
Custom Axis Titles
Customize the titles of the x and y axes with the xaxis_titles and yaxis_titles arguments.
Legend Customization
Legends are customizable with unsafe_update_figure. Generally, legend customization is safe.
Legend Position
By default, the legend is placed in the top right corner of the plot.
Move the legend around the plot with x, y, xanchor, and yanchor arguments to the update_layout method.
xanchor and yanchor set the anchor point of the legend, which determine which part of the legend box is used to position the legend.
x and y set the position of the anchor point relative to the plot area.
For x and y, 0 is the left or bottom of the plot area and 1 is the right or top of the plot area.
Negative values or values above 1 for x and y move the anchor point outside the plot area.
xanchor can be set to "auto", "left", "center", or "right" and yanchor can be set to "auto", "top", "middle", or "bottom".
Legend Overlay
Overlay the legend by positioning the top left corner of the legend just inside the plot area.
Horizontal Legend
Customize the legend to be horizontal by updating the layout with orientation="h".
Move the legend just outside the bottom of the plot area by setting y to a negative value.
Hide Legend
Hide the legend by updating the layout with showlegend=False.