@@ -306,6 +306,7 @@ def negative_1_if_count_is_odd(count):
306306
307307def swarm (
308308 X_series ,
309+ fig_title ,
309310 point_size = 16 ,
310311 fig_width = 800 ,
311312 gap_multiplier = 1.2 ,
@@ -372,7 +373,6 @@ def swarm(
372373 # in px.
373374 row[" y" ] = (row[" y_slot" ]// 2 ) * \
374375 negative_1_if_count_is_odd(row[" y_slot" ])* point_size* gap_multiplier
375- print (row[" y" ])
376376
377377 # if the number of points is even, move y-coordinates down to put an equal
378378 # number of entries above and below the axis
@@ -392,6 +392,7 @@ def swarm(
392392 df,
393393 x = " x" ,
394394 y = " y" ,
395+ title = fig_title,
395396 )
396397 # we want to suppress the y coordinate in the hover value because the
397398 # y-coordinate is irrelevant/misleading
@@ -413,9 +414,10 @@ def swarm(
413414
414415
415416df = 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,
419421# 2, 2, 2, 3, 3, 2.05, 2.1, 2.2, 2.5, 12]))
420422fig.show()
421423```
0 commit comments