How can I change the root container color? i tried root_color and marker_colors, neither work.
# Function template for treemap graphs
def treemap_temp(categories, title, path, values, colors):
fig = px.treemap(categories, path=path, values=values, color=colors,
height=700, title=title, color_continuous_scale=['lime', 'red'])
fig.data[0].textinfo = 'label+text+value'
fig.show()
cities = df['City'].unique()
# Preparing the graph data
number_cities = df["City"].value_counts()
values = number_cities.values
categories = pd.DataFrame(data=number_cities.index, columns=["City"])
categories['Reported Crimes'] = values
# Plotting the data
treemap_temp(categories,
"Crime Intensity in Montgomery Cities",
["City"],
categories['Reported Crimes'],
categories['Reported Crimes'])
Thanks for your time and help
it changes nothing bro
here’s the CSV if u wanna try it yourself
TARpa
4
Adding px.Constant(" "), will change the colour but you can’t specify it as it’s from the colour scheme.
It just doesn’t work with color_continuous_scale. You can either make it using a discrete colour sequence or choose a different colour scheme.
import pandas as pd
import plotly.express as px
df = pd.read_csv('Crime_Dataset.csv', low_memory=False)
city_crime_counts = df.groupby('City', as_index=False).size()
city_crime_counts.rename(columns={'size': 'Reported Crimes'}, inplace=True)
fig = px.treemap(city_crime_counts, path=[px.Constant("Montgomery"), 'City'], values='Reported Crimes', color='Reported Crimes',
height=700, title="Crime Intensity in Montgomery Cities", color_continuous_scale='RdBu_r')
Unfortunate that I have to pick between those two.
I changed the color scheme, so now the root container doesn’t look out of place anymore
Thanks for your help @TARpa