MCPcopy Index your code
hub / github.com/plotly/plotly.py / violin_dict

Function violin_dict

plotly/figure_factory/_violin.py:362–429  ·  view source on GitHub ↗

Refer to FigureFactory.create_violin() for docstring. Returns fig for violin plot without colorscale.

(
    data,
    data_header,
    group_header,
    colors,
    use_colorscale,
    group_stats,
    rugplot,
    sort,
    height,
    width,
    title,
)

Source from the content-addressed store, hash-verified

360
361
362def violin_dict(
363 data,
364 data_header,
365 group_header,
366 colors,
367 use_colorscale,
368 group_stats,
369 rugplot,
370 sort,
371 height,
372 width,
373 title,
374):
375 """
376 Refer to FigureFactory.create_violin() for docstring.
377
378 Returns fig for violin plot without colorscale.
379
380 """
381
382 # collect all group names
383 group_name = []
384 for name in data[group_header]:
385 if name not in group_name:
386 group_name.append(name)
387
388 if sort:
389 group_name.sort()
390
391 # check if all group names appear in colors dict
392 for group in group_name:
393 if group not in colors:
394 raise exceptions.PlotlyError(
395 "If colors is a dictionary, all "
396 "the group names must appear as "
397 "keys in colors."
398 )
399
400 gb = data.groupby([group_header])
401 L = len(group_name)
402
403 fig = make_subplots(
404 rows=1, cols=L, shared_yaxes=True, horizontal_spacing=0.025, print_grid=False
405 )
406
407 for k, gr in enumerate(group_name):
408 vals = np.asarray(gb.get_group(gr)[data_header], float)
409 plot_data, plot_xrange = violinplot(vals, fillcolor=colors[gr], rugplot=rugplot)
410 for item in plot_data:
411 fig.append_trace(item, 1, k + 1)
412
413 # add violin plot labels
414 fig["layout"].update(
415 {"xaxis{}".format(k + 1): make_XAxis(group_name[k], plot_xrange)}
416 )
417
418 # set the sharey axis style
419 fig["layout"].update({"yaxis{}".format(1): make_YAxis("")})

Callers 1

create_violinFunction · 0.85

Calls 8

make_subplotsFunction · 0.90
violinplotFunction · 0.85
make_XAxisFunction · 0.85
make_YAxisFunction · 0.85
append_traceMethod · 0.80
sortMethod · 0.45
updateMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected