Skip to content

Instantly share code, notes, and snippets.

@erdogant
Last active February 4, 2023 23:06
Show Gist options
  • Select an option

  • Save erdogant/776d56d5d2c7087078a76d8390f86dc1 to your computer and use it in GitHub Desktop.

Select an option

Save erdogant/776d56d5d2c7087078a76d8390f86dc1 to your computer and use it in GitHub Desktop.
d3blocks
# Import library
from d3blocks import D3Blocks
# Initialize
d3 = D3Blocks()
# import example
df = d3.import_example('cancer')
# Tooltip
tooltip=df['labels'].values + ' <br /> Survival: ' + df['survival_months'].astype(str).values
# Make the plot
d3.violin(x=df['labels'].values, # class labels on the x axis
y=df['age'].values, # Age
tooltip=tooltip, # Tooltip for hovering
bins=50, # Bins used for the histogram
size=df['survival_months'].values/10, # Dotsize
x_order=['acc','kich', 'brca','lgg','blca','coad','ov'], # Keep only these classes and plot in this order.
figsize=[None, None], # Figure size is automatically determined.
filepath='violine_demo.html')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment