@@ -306,6 +306,7 @@ def negative_1_if_count_is_odd(count):
306
306
307
307
def swarm (
308
308
X_series ,
309
+ fig_title ,
309
310
point_size = 16 ,
310
311
fig_width = 800 ,
311
312
gap_multiplier = 1.2 ,
@@ -372,7 +373,6 @@ def swarm(
372
373
# in px.
373
374
row[" y" ] = (row[" y_slot" ]// 2 ) * \
374
375
negative_1_if_count_is_odd(row[" y_slot" ])* point_size* gap_multiplier
375
- print (row[" y" ])
376
376
377
377
# if the number of points is even, move y-coordinates down to put an equal
378
378
# number of entries above and below the axis
@@ -392,6 +392,7 @@ def swarm(
392
392
df,
393
393
x = " x" ,
394
394
y = " y" ,
395
+ title = fig_title,
395
396
)
396
397
# we want to suppress the y coordinate in the hover value because the
397
398
# y-coordinate is irrelevant/misleading
@@ -413,9 +414,10 @@ def swarm(
413
414
414
415
415
416
df = px.data.iris() # iris is a pandas DataFrame
416
- fig = swarm(df[" sepal_length" ])
417
- # here's a more interesting test case for collision avoidance:
418
- # fig = swarm(pd.Series([1, 1.5, 1.78, 1.79, 1.85, 2,
417
+ fig = swarm(df[" sepal_length" ], " Sepal length distribution from 150 iris samples" )
418
+ # The iris data set entries are rounded so there are no collisions.
419
+ # a more interesting test case for collision avoidance is:
420
+ # fig = swarm(pd.Series([1, 1.5, 1.78, 1.79, 1.85, 2,
419
421
# 2, 2, 2, 3, 3, 2.05, 2.1, 2.2, 2.5, 12]))
420
422
fig.show()
421
423
```
0 commit comments