You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/python/figurewidget.md
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ jupyter:
22
22
pygments_lexer: ipython3
23
23
version: 3.6.5
24
24
plotly:
25
-
description: Introduction to the new Plotly FigureWidget
25
+
description: Introduction to the Plotly FigureWidget
26
26
display_as: chart_events
27
27
language: python
28
28
layout: base
@@ -34,6 +34,12 @@ jupyter:
34
34
redirect_from: /python/ipython-widgets/
35
35
---
36
36
37
+
The Plotly FigureWidget allows you to add Plotly charts as interactive widgets in Jupyter and other compatible notebooks. To use the FigureWidget, you'll need to install `anywidget`:
Swarm plots show the distribution of values in a column by giving each entry one dot and adjusting the y-value so that dots do not overlap and appear symmetrically around the y=0 line. They complement [histograms](https://plotly.com/python/histograms/), [box plots](https://plotly.com/python/box-plots/), and [violin plots](https://plotly.com/python/violin/). This example could be generalized to implement a swarm plot for multiple categories by adjusting the y-coordinate for each category.
290
+
291
+
```python
292
+
import pandas as pd
293
+
import plotly.express as px
294
+
import collections
295
+
296
+
297
+
defnegative_1_if_count_is_odd(count):
298
+
# if this is an odd numbered entry in its bin, make its y coordinate negative
299
+
# the y coordinate of the first entry is 0, so entries 3, 5, and 7 get
300
+
# negative y coordinates
301
+
if count %2==1:
302
+
return-1
303
+
else:
304
+
return1
305
+
306
+
307
+
defswarm(
308
+
X_series,
309
+
fig_title,
310
+
point_size=16,
311
+
fig_width=800,
312
+
gap_multiplier=1.2,
313
+
bin_fraction=0.95, # slightly undersizes the bins to avoid collisions
314
+
):
315
+
# sorting will align columns in attractive c-shaped arcs rather than having
316
+
# columns that vary unpredictably in the x-dimension.
317
+
# We also exploit the fact that sorting means we see bins sequentially when
318
+
# we add collision prevention offsets.
319
+
X_series = X_series.copy().sort_values()
320
+
321
+
# we need to reason in terms of the marker size that is measured in px
322
+
# so we need to think about each x-coordinate as being a fraction of the way from the
323
+
# minimum X value to the maximum X value
324
+
min_x =min(X_series)
325
+
max_x =max(X_series)
326
+
327
+
list_of_rows = []
328
+
# we will count the number of points in each "bin" / vertical strip of the graph
329
+
# to be able to assign a y-coordinate that avoids overlapping
330
+
bin_counter = collections.Counter()
331
+
332
+
for x_val in X_series:
333
+
# assign this x_value to bin number
334
+
# each bin is a vertical strip slightly narrower than one marker
# remember the "y-slot" which tells us the number of points in this bin and is sufficient to compute the y coordinate unless there's a collision with the point to its left
If Plotly Express does not provide a good starting point, it is possible to use [the more generic `go.Scatter` class from `plotly.graph_objects`](/python/graph-objects/). Whereas `plotly.express` has two functions `scatter` and `line`, `go.Scatter` can be used both for plotting points (makers) or lines, depending on the value of `mode`. The different options of `go.Scatter` are documented in its [reference page](https://plotly.com/python/reference/scatter/).
Copy file name to clipboardExpand all lines: doc/python/static-image-export.md
+2-7Lines changed: 2 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -64,13 +64,6 @@ Plotly also provides a CLI for installing Chrome from the command line.
64
64
65
65
Run `plotly_get_chrome` to install Chrome.
66
66
67
-
You can also install Chrome from within Python using `plotly.io.install_chrome()`
68
-
69
-
```python
70
-
import plotly.io as pio
71
-
72
-
pio.install_chrome()
73
-
```
74
67
75
68
See the **Additional Information on Browsers with Kaleido** section below for more details on browser compatibility for Kaleido.
76
69
@@ -273,6 +266,8 @@ The following settings are available.
273
266
274
267
`mathjax`: Location of the MathJax bundle needed to render LaTeX characters. Defaults to a CDN location. If fully offline export is required, set this to a local MathJax bundle.
275
268
269
+
`plotlyjs`: Location of the Plotly.js bundle to use. Can be a local file path or URL. By default, Kaleido uses the Plotly.js bundle included with Plotly.py.
270
+
276
271
`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.
277
272
278
273
`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.
Copy file name to clipboardExpand all lines: doc/python/tile-county-choropleth.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ jupyter:
22
22
pygments_lexer: ipython3
23
23
version: 3.10.0
24
24
plotly:
25
-
description: How to make a choropleth map of US counties in Python with Plotly.
25
+
description: How to make tile choropleth maps in Python with Plotly.
26
26
display_as: maps
27
27
language: python
28
28
layout: base
@@ -254,4 +254,4 @@ fig.show()
254
254
255
255
See [function reference for `px.choropleth_map`](https://plotly.com/python-api-reference/generated/plotly.express.choropleth_map) or https://plotly.com/python/reference/choroplethmap/ for more information about the attributes available.
256
256
257
-
For Mapbox-based tile maps, see [function reference for `px.choropleth_mapbox`](https://plotly.com/python-api-reference/generated/plotly.express.choropleth_mapbox) or https://plotly.com/python/reference/choroplethmapbox/.
257
+
For (deprecated) Mapbox-based tile maps, see [function reference for `px.choropleth_mapbox`](https://plotly.com/python-api-reference/generated/plotly.express.choropleth_mapbox) or https://plotly.com/python/reference/choroplethmapbox/.
0 commit comments