0
이 코드의 어딘가에 버그가 있지만 찾을 수 없습니다. 첫 번째 열에는 비율이 표시되지 않습니다. 빠른 수정이어야합니다!첫 번째 열에 백분율이 표시되지 않습니다
import pandas as pd
import matplotlib.pyplot as plt
s = pd.Series(
[8, 24, 21, 23, 24],
index = ["Your Plan", "Benchmark", "Region", "Industry", "Size"]
)
#Set descriptions:
plt.title("INSERT TITLE HERE, PLEASE")
plt.ylabel('Percentage of EEs Waiving')
#Set tick colors:
ax = plt.gca()
ax.tick_params(axis='x', colors='black')
ax.tick_params(axis='y', colors='black')
#Plot the data:
my_colors = ['#ffc000','#305496', '#8ea9db', '#b4c6e7', '#D9E1F2'] #red, green, blue, black, etc.
s.plot(
kind="bar",
color=my_colors,
)
# Rotate the desired axis (or undo the rotation)
ax.set_xticklabels(ax.xaxis.get_majorticklabels(), rotation=0)
# Set the Y Axis Limits
ax.set_ylim([0,100])
#Adds data labels to top of bars
for p in ax.patches[1:]:
h = p.get_height()
x = p.get_x()+p.get_width()/2.
if h != 0:
ax.annotate("%g" % p.get_height()+'%', xy=(x,h), xytext=(0,8), rotation=0,
textcoords="offset points", ha="center", va="bottom")
plt.show()
plt.savefig("PlanOffered.png")
또한 "계획"과 벤치 마크 열 사이에 줄을 추가하여 멋진 열을 구분할 수 있다면! 많은 사람들에게 감사드립니다!
굉장! 고맙습니다. 우리가 선을 검은 색, 퇴색 (부분적으로 투명 함) 및 대시 선 형식으로 만들 수있는 기회가 있습니까? –