0

Still a beginner in coding. I have created a multiple bar graphs on a single plot and now wanted scores to print on the two different bargraphs. Since both the bar graphs are taken from different dataframes i am able to print only one bar graph i.e. scores considered from data (mentioned in the code). However printing is happening because of the for loop, plt.text but not on the correct bar graph as in the position of printing is incorrect.

And please suggest how to print on the first/second bar graph for which i need to select the scores from data and Data1

X = ['A','B','C']
data = customer_survey_TSS['Advocacy4']/4
Data1 = Emp_Survey_TSS['Advocacy']

  
X_axis = np.arange(len(X))

plt.rcParams["figure.figsize"] = (10, 5)

  
plt.bar(X_axis - 0.2, data, 0.4, label = 'Customer scores')
plt.bar(X_axis + 0.2, Data1, 0.4, label = 'Employee scores')
  

plt.xticks(X_axis, X)
plt.xlabel("Quarters-FY21")
plt.ylabel("Aggregate score of customer & Employee")
plt.title("Customer-Employee")
plt.legend(bbox_to_anchor=(1.05, 1.0), loc='upper left')

    for index,data in enumerate(VOC):
        plt.text(x=index , y =data+0.0065 , s=f"{data}" , fontdict=dict(fontsize=13))
        

plt.show()

enter image description here

James Z
  • 12,209
  • 10
  • 24
  • 44
Trend
  • 1
  • 1
  • 4
  • 1
    See this: [https://matplotlib.org/stable/gallery/lines_bars_and_markers/bar_label_demo.html](https://matplotlib.org/stable/gallery/lines_bars_and_markers/bar_label_demo.html) – r-beginners Feb 04 '22 at 08:21
  • And since you're working with dataframes, consider combining the relevant columns in 1 dataframe and using [`df.plot.bar()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.plot.bar.html). – tdy Feb 04 '22 at 08:28

0 Answers0