Skip to content

Instantly share code, notes, and snippets.

@ravi07bec
Created October 29, 2020 06:38
Show Gist options
  • Save ravi07bec/49beafad14342cbe918baf67d52e3775 to your computer and use it in GitHub Desktop.
Save ravi07bec/49beafad14342cbe918baf67d52e3775 to your computer and use it in GitHub Desktop.
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import pandas as pd
df1 = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/718417069ead87650b90472464c7565dc8c2cb1c/sunburst-coffee-flavors-complete.csv')
df2 = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/718417069ead87650b90472464c7565dc8c2cb1c/coffee-flavors.csv')
fig = make_subplots(
rows = 1, cols = 2,
column_widths = [0.4, 0.4],
specs = [[{'type': 'treemap', 'rowspan': 1}, {'type': 'treemap'}]]
)
fig.add_trace(
go.Treemap(
ids = df1.ids,
labels = df1.labels,
parents = df1.parents),
col = 1, row = 1)
fig.add_trace(
go.Treemap(
ids = df2.ids,
labels = df2.labels,
parents = df2.parents,
maxdepth = 3),
col = 2, row = 1)
fig.update_layout(
margin = {'t':0, 'l':0, 'r':0, 'b':0}
)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment