I'm trying to visualize if a group of people live in their birthplace or not in different years (pandas df). But the histplot colors are much darker than what I have specified as if there is a dark filter on the plot itself. The colors in the legend corresponds to what I assign. How can I fix this/what am I doing wrong? I am still new to python and visualizations in seaborn.
I have tried to specify both a color_palette, set.palette() and palette and to assign different colors, but the plot itself is always very dark.
Code:
#import packages
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
#Create dataset
d = {'ID': ['ID-1', 'ID-1', 'ID-1', 'ID-1', 'ID-1', 'ID-2', 'ID-2', 'ID-2', 'ID-2', 'ID-2', 'ID-3', 'ID-3', 'ID-3', 'ID-3', 'ID-3'],
'year': ['birthyear', 'year_1', 'year_2', 'year_3', 'year_4', 'birthyear', 'year_1', 'year_2', 'year_3', 'year_4', 'birthyear', 'year_1', 'year_2', 'year_3', 'year_4'],
'living_where': ['lives in birthplace', 'lives in birthplace', 'lives elsewhere', 'lives in birthplace', 'dead', 'lives in birthplace', 'lives elsewhere', 'lives elsewhere', 'lives elsewhere', 'lives elsewhere', 'lives in birthplace', 'lives elsewhere', 'lives elsewhere', 'dead', 'dead']}
df = pd.DataFrame(data=d)
#Create histplot
ax = sns.histplot(data=df, x="year", y='ID', hue="living_where", palette='pastel')
sns.move_legend(
ax, "lower center",
bbox_to_anchor=(.5, 1), ncol=4, title=None, frameon=False)
#Even if I specify a color to be white it becomes grey
pal = ['blue', 'white', 'red']
#Create histplot
ab = sns.histplot(data=df, x="year", y='ID', hue="living_where", palette=pal)
sns.move_legend(
ab, "lower center",
bbox_to_anchor=(.5, 1), ncol=4, title=None, frameon=False)
color palette set as 'pastel':
color palette set as 'blue, 'white' and 'red'