Last active
September 14, 2020 15:12
-
-
Save stanlee321/6ce1c1785ac344feffb6b9f1837d33cc to your computer and use it in GitHub Desktop.
treemaps python
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
| def plot_treemap(df, values="count", columns = [], title='Proyectos en curso por Departamento', width=1200, height=600): | |
| fig1 = px.treemap(df.sort_values(by=values, ascending=False).reset_index(drop=True), | |
| path=columns, values=values, title=title, | |
| color_discrete_sequence = px.colors.qualitative.Prism, width=width,height=height, maxdepth = 4, ) | |
| fig1.data[0].textinfo = 'label+text+value+percent entry' | |
| py.offline.iplot(fig1) | |
| return fig1 | |
| # Use | |
| fig1 = plot_treemap(dfs,values="Value", columns =["Name", "Departamento"], title="<b>Proyectos en curso:</b> Ministerio -> Departamento") | |
| fig1.write_html(f"fig1_treeplot_Departamentos_{now}.html") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment