Last active
November 15, 2022 18:47
-
-
Save erdogant/a8b5d20c32f990ff2d61ed1169d3004e to your computer and use it in GitHub Desktop.
D3Blocks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Load library | |
| from d3blocks import D3Blocks | |
| # Initialize | |
| d3 = D3Blocks(frame=True) | |
| # Import example | |
| df = d3.import_example('cancer') | |
| # Setup the tooltip | |
| tooltip=df['labels'].values + ' <br /> Survival: ' + df['survival_months'].astype(str).str[0:4].values | |
| # Set the size | |
| size = df['survival_months'].fillna(1).values / 10 | |
| # Set all propreties | |
| d3.scatter(df['x'].values, # tSNE x-coordinates | |
| df['y'].values, # tSNE y-coordinates | |
| x1=df['PC1'].values, # PC1 x-coordinates | |
| y1=df['PC2'].values, # PC2 y-coordinates | |
| size=size, # Size | |
| color=df['labels'].values, # Hex-colors or classlabels | |
| stroke='#000000', # Edge color | |
| opacity=0.7, # Opacity | |
| tooltip=tooltip, # Tooltip | |
| cmap='tab20', # Colormap | |
| scale=True, # Scale the datapoints | |
| label_radio=['tSNE', 'PCA'], | |
| figsize=[800, 600], | |
| filepath='c://temp//scatter_demo.html', | |
| ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment