1
다음 코드에 의해 생성 된 boxplots에 여백을 수동으로 추가하고 싶습니다. 현재 박스 플롯은 코너 (끝)에 너무 많이 있습니다. 일반적으로 많은 박스 플롯 (이 샘플 코드와 달리)이 있는데, 이는 코드 에서처럼 똑같이 간격을두고 싶지만 양쪽에 여백을두고 싶습니다.여백 Boxplots Matplotlib
내가
import matplotlib.pyplot as plt
statistic_dict = {0.40000000000000002: [0.36003616645322273, 0.40526649416305677, 0.46522159350924536], 0.20000000000000001: [0.11932912803730165, 0.23235825966896217, 0.12380728472472625]}
def draw_boxplot(y_values, x_values, edge_color, fill_color):
bp = plt.boxplot(y_values, patch_artist=True, positions=x_values, widths=(0.05,0.05))
for element in ['boxes', 'whiskers', 'fliers', 'medians', 'caps']:
plt.setp(bp[element], color=edge_color)
plt.xlabel("x label ")
plt.ylabel("y label ")
plt.title("Title")
for patch in bp['boxes']:
patch.set(facecolor=fill_color)
y_values = statistic_dict.values()
x_values = statistic_dict.keys()
draw_boxplot(y_values, x_values, "skyblue", "white")
plt.gca().autoscale()
plt.savefig('fileName.png', bbox_inches='tight')
plt.close()
Matplotlib 1.3.1은 4 세 이상입니다. 솔루션 [here] (https://stackoverflow.com/a/47926303/4124317)이 잘 작동하도록 업그레이드 할 것을 권장합니다. – ImportanceOfBeingErnest
업그레이드하는 데 문제가 있습니다 .... – user58925