Here is a tip to map a color on the values of each group of a treemap.
#libraries import matplotlib import matplotlib.pyplot as plt import pandas as pd import squarify # pip install squarify (algorithm for treemap)</pre> # Create a dataset: my_values=[i**3 for i in range(1,100)] # create a color palette, mapped to these values cmap = matplotlib.cm.Blues mini=min(my_values) maxi=max(my_values) norm = matplotlib.colors.Normalize(vmin=mini, vmax=maxi) colors = [cmap(norm(value)) for value in my_values] # Change color squarify.plot(sizes=my_values, alpha=.8, color=colors ) plt.axis('off') plt.show()
I am using anaconda version of python. I try pip install squarify and I can not import squarify. What is most efficient way to use squarify with Anaconda Jupyter notebook?
Hi Will,
I followed the instruction of the GitHub page of the scarify library. I used pip as well and it worked fine. May be you could try to install it from source doing
git clone git://github.com/laserson/squarify.git
cd squarify
python setup.py install
How can I change the color of the labels?