I would like to show the percentages of each bar on my horizontal bar chart but I am unsure how to do it. Also, ideally I would have the percentages at the ends of each bar if that were possible?
Here is my current script:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
%matplotlib inline
...
percentage = []
for i in top_ten_districts:
percentage.append(int((i / total_ads)*100))
percentage = ['{}%'.format(x) for x in percentage]
top_ten_districts = active_ads.district.value_counts().head(10)
plt.barh(top_ten_districts.index, top_ten_districts)
plt.xlabel('num of ads')
plt.ylabel('county')
plt.title('TOP 10 DISTRICTS')
top_ten_districts
I would like to have the '%' sign after each percentage on the chart, however, when I execute the script, I get the following:
ConversionError: Failed to convert value(s) to axis units: '22%'
current chart: