Home > Mobile >  Adding text as asterix with matplotlib
Adding text as asterix with matplotlib

Time:07-10

Below you can see my data and facet plot in matplotlib.

import pandas as pd
import numpy as np
pd.set_option('max_columns', None)
import matplotlib.pyplot as plt

data = {
         'type_sale': ['g_1','g_2','g_3','g_4','g_5','g_6','g_7','g_8','g_9','g_10'],
         'open':[70,20,24,80,20,20,60,20,20,20],
         'closed':[30,14,20,10,10,40,10,10,10,10],
        }

df = pd.DataFrame(data, columns = ['type_sale',
                                   'open',
                                   'closed',
                                   ])

fig, axs = plt.subplots(2,2, figsize=(8,6))
plt.subplots_adjust(wspace=0.2, hspace=0.6)
df.plot(x='type_sale', kind='bar', stacked=True, title='Stacked Bar Graph by dataframe',ax=axs[0,0])
df.plot(x='type_sale', kind='bar', stacked=True, title='Stacked Bar Graph by dataframe', ax=axs[0,1])
df.plot(x='type_sale', kind='bar', stacked=True, title='Stacked Bar Graph by dataframe',ax=axs[1,0])
df.plot(x='type_sale', kind='bar', stacked=True,title='Stacked Bar Graph by dataframe', ax=axs[1,1])

plt.suptitle(t='Stacked Bar Graph by dataframe', fontsize=16)
plt.show()

Now I want to enclose it with a black line, this facet, and add text with an asterisk similar to the picture shown below

enter image description here

So can anybody help me how to solve this problem?

CodePudding user response:

Here's how I implemented it, based on enter image description here

  • Related