Skip to content

Help supplying discrete RGB colors #4

@piazze2

Description

@piazze2

Hi,

Love the code! It works really well. I'm trying to supply my own list of RGB values:
['#a6ce39','#ccdb99','#739d00','#00708b','#4c9dbb','#00455f','#f2a900','#991e66','#999899','#515250']

This should be similar to your final example, with the exception that your colors were written ("red", "cyan", etc).

Code below, and result attached.

Thanks!

Erin
#Read in dataframe
df = pd.read_csv("Themes.csv")
#Create figure
fig, ax = plt.subplots(figsize=(7,7), dpi=100)
#Create Treemap
trc = tr.treemap(
ax, df, area='# Genes', labels='Theme',cmap=['#a6ce39','#ccdb99','#739d00','#00708b','#4c9dbb','#00455f','#f2a900','#991e66','#999899','#515250'],
rectprops={'ec':'w', 'lw':2},
textprops={'c':'black', 'fontstyle':'normal','reflow':True},
)
#No axis needed
ax.axis('off')
#Save figure
fig.savefig('fig2.svg', dpi='figure', bbox_inches='tight')

fig2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions