Skip to content

Commit 2de1059

Browse files
committed
Update docs for release
1 parent f94e304 commit 2de1059

4 files changed

Lines changed: 77 additions & 0 deletions

File tree

doc/python/hover-text-and-formatting.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,24 @@ fig.update_layout(hovermode="x unified")
8383
fig.show()
8484
```
8585

86+
#### Sorting Unified Hover Labels by Value
87+
88+
*New in 6.8*
89+
90+
In `'x unified'` and `'y unified'` hover modes, items in the hover label appear in the order their traces were added to the figure. Set `layout.hoversort` to `"descending"` or `"ascending"` to instead sort the items by the value being shown, which makes it easier to compare traces at a glance.
91+
92+
```python
93+
import plotly.express as px
94+
95+
df = px.data.stocks()
96+
97+
fig = px.line(df, x="date", y=df.columns[1:], title="layout.hoversort='descending'")
98+
fig.update_traces(hovertemplate=None)
99+
fig.update_layout(hovermode="x unified", hoversort="descending")
100+
101+
fig.show()
102+
```
103+
86104
#### Customize Title in Unified Hover Mode
87105

88106
*New in 6.3*
@@ -221,6 +239,22 @@ fig.update_layout(
221239
fig.show()
222240
```
223241

242+
### Emitting Hover and Click Events Anywhere in the Plot Area
243+
244+
*New in 6.7*
245+
246+
By default, hover and click events are only emitted when the cursor is over a trace. Set `layout.hoveranywhere=True` or `layout.clickanywhere=True` to emit these events anywhere inside the plot area, including over empty space. The events carry the cursor's data coordinates, which is useful when building interactive callbacks (for example, in [Dash](https://dash.plotly.com/)) that need to respond to clicks on locations that don't correspond to a specific data point.
247+
248+
```python
249+
import plotly.express as px
250+
251+
df = px.data.iris()
252+
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
253+
fig.update_layout(hoveranywhere=True, clickanywhere=True)
254+
255+
fig.show()
256+
```
257+
224258
### Customizing Hover text with Plotly Express
225259

226260
Plotly Express functions automatically add all the data being plotted (x, y, color etc) to the hover label. Many Plotly Express functions also support configurable hover text. The `hover_data` argument accepts a list of column names to be added to the hover tooltip, or a dictionary for advanced formatting (see the next section). The `hover_name` property controls which column is displayed in bold as the tooltip title.

doc/python/legend.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,25 @@ fig.add_shape(
154154
fig.show()
155155
```
156156

157+
##### Per-Slice `legendrank` for Pie Traces
158+
159+
*New in 6.8*
160+
161+
For `pie` traces, `legendrank` also accepts an array so that each slice can be ranked individually. In the example below, the slices appear in the legend in the order specified by `legendrank` (lowest rank first), independent of the order of `values`.
162+
163+
```python
164+
import plotly.graph_objects as go
165+
166+
fig = go.Figure(
167+
go.Pie(
168+
labels=["Oxygen", "Hydrogen", "Carbon", "Nitrogen", "Other"],
169+
values=[4500, 2500, 1053, 500, 600],
170+
legendrank=[3, 1, 2, 5, 4],
171+
)
172+
)
173+
fig.show()
174+
```
175+
157176
#### Showing and Hiding the Legend
158177

159178
By default the legend is displayed on Plotly charts with multiple traces, and this can be explicitly set with the `layout.showlegend` attribute.

doc/python/static-image-export.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ The following settings are available.
277277

278278
`topojson`: Location of the topojson files needed to render choropleth traces. Defaults to a CDN location. If fully offline export is required, set this to a local directory containing the Plotly.js topojson files.
279279

280+
`headers`: *New in 6.8.* A dict of HTTP headers Kaleido sends when fetching external resources during image export (for example, when fetching OpenStreetMap tiles for tile maps). Defaults to `{"X-Requested-With": "plotly.py"}`, which is required to comply with the [OpenStreetMap tile usage policy](https://operations.osmfoundation.org/policies/tiles/). Requires Kaleido v1.3.0 or later.
281+
280282
`mapbox_access_token`: The default Mapbox access token (Kaleido v0 only). Mapbox traces are deprecated. See the [MapLibre Migration](https://plotly.com/python/mapbox-to-maplibre/) page for more details.
281283

282284
### Set Defaults

doc/python/subplots.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,28 @@ fig.update_layout(height=500, width=700,
156156
fig.show()
157157
```
158158

159+
#### Customizing the Subplot Title Font
160+
161+
*New in 6.8*
162+
163+
Use the `font` argument of `make_subplots` to customize the font used for `subplot_titles`, `column_titles`, `row_titles`, `x_title`, and `y_title`. The argument accepts a dict with any of the standard [font attributes](https://plotly.com/python/reference/layout/annotations/#layout-annotations-items-annotation-font) (`family`, `size`, `color`, `weight`, etc.).
164+
165+
```python
166+
from plotly.subplots import make_subplots
167+
import plotly.graph_objects as go
168+
169+
fig = make_subplots(
170+
rows=1, cols=2,
171+
subplot_titles=("Plot 1", "Plot 2"),
172+
font=dict(family="Courier New, monospace", size=20, color="RebeccaPurple"),
173+
)
174+
175+
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6]), row=1, col=1)
176+
fig.add_trace(go.Scatter(x=[20, 30, 40], y=[50, 60, 70]), row=1, col=2)
177+
178+
fig.show()
179+
```
180+
159181
#### Subplots with Annotations
160182

161183
```python

0 commit comments

Comments
 (0)