def map(self) -> go.Figure: """Produce an interactive tree map of the repository.""" treemap = ep.Treemap(self.map_node_sizes(), text=self.map_node_text, hoverinfo=self.map_hoverinfo(), marker_colors=self.map_node_color, marker_colorscale=self.map_colorscale(), root_label=self.repo, branchvalues='total') fig = go.Figure(treemap) fig.update_layout(margin=dict(l=0, r=0, t=30, b=0)) return fig
if life_exp > 0: pop = pop_and_exp.population.loc[item].sum( ) if item else pop_and_exp.population.sum() return 'Population: {:,}<br>Life expectancy: {:.2f}'.format( int(pop), life_exp) # %% [markdown] # # Plot # %% import plotly.graph_objects as go import easyplotly as ep treemap = ep.Treemap( pop_and_exp.population, hoverinfo='label+text', text=text, root_label='World', # magic underscore notation marker_colors=life_expectancy, marker_colorscale='RdBu') layout = go.Layout( title='World Population and Life Expectancy<br>Data from the World Bank', height=600) go.Figure(treemap, layout) # %%