I am not quite sure about the hash pattern you mentioned.
Here is my understanding, you want to achieve two things.
First, color the bars having different property.
Second, create a legend box on the plot.
The approach below is way to fulfill your purpose.
1. Color the bars.
This step can be easily done with setting up the parameter palette
in the function sns.barplot
. You shall input a sequence of colors into it in hex format (there also lots of other ways exist).
color_eng = "#94698b"
color_non_eng = "#4369ef"
# the sequence length is the number of bars.
palette = [color_eng, color_eng, color_non_eng, color_eng, color_non_eng]
ax2 = sns.barplot(x='country_code', y='raised_amount_usd',
data=top9, estimator=np.sum, palette=palette)
2. Create a legend.
To create a customized legend box, we could set up the handles of the axes with manually created patches (I borrowed the code idea from this SO answer).
import matplotlib.patches as mpatches
p_eng = mpatches.Patch(color=color_eng, label='English speaking country')
p_non_eng = mpatches.Patch(color=color_non_eng, label='non-English speaking country')
ax2.legend(handles=[p_eng, p_non_eng])
The final code shall looks like:
import matplotlib.patches as mpatches
top9 = master_frame[master_frame['country_code'].isin(["USA","CHN","GBR","IND","CAN","ISR","FRA","DEU","SWE"])]
plt.figure(figsize=(10,5))
color_eng = "#94698b"
color_non_eng = "#4369ef"
# the sequence length is the number of bars.
# Shall be composed by you
palette = [color_eng, color_eng, color_non_eng, color_eng, .......]
ax2 = sns.barplot(x='country_code', y='raised_amount_usd',
data=top9, estimator=np.sum, palette=palette)
p_eng = mpatches.Patch(color=color_eng, label='English speaking country')
p_non_eng = mpatches.Patch(color=color_non_eng, label='non-English speaking country')
ax2.legend(handles=[p_eng, p_non_eng])
ax2.set_yscale('log')
ax2.set(xlabel='Funding by country', ylabel='Total amount of investments')
ax2.set_title('Investment distribution Country wise',fontsize =18, weight='bold')
plt.show()