Występuje dziwne zachowanie w funkcji matplotlib
boxplot
, kiedy używam kształtu "". Używam kodu, który napisałem jakiś czas temu i nigdy nie miałem takich problemów - zastanawiam się, jaki jest problem. Jakieś pomysły?Dziwne zachowanie matplotlibs boxplot przy użyciu kształtu karbu
Po włączeniu kształt karbu poza tym wygląda normalnie chociaż
Byłby to kod:
def boxplot_modified(data):
fig = plt.figure(figsize=(8,6))
ax = plt.subplot(111)
bplot = plt.boxplot(data,
#notch=True, # notch shape
vert=True, # vertical box aligmnent
sym='ko', # red circle for outliers
patch_artist=True, # fill with color
)
# choosing custom colors to fill the boxes
colors = 3*['lightgreen'] + 3*['lightblue'], 'lightblue', 'lightblue', 'lightblue']
for patch, color in zip(bplot['boxes'], colors):
patch.set_facecolor(color)
# modifying the whiskers: straight lines, black, wider
for whisker in bplot['whiskers']:
whisker.set(color='black', linewidth=1.2, linestyle='-')
# making the caps a little bit wider
for cap in bplot['caps']:
cap.set(linewidth=1.2)
# hiding axis ticks
plt.tick_params(axis="both", which="both", bottom="off", top="off",
labelbottom="on", left="off", right="off", labelleft="on")
# adding horizontal grid lines
ax.yaxis.grid(True)
# remove axis spines
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
ax.spines["bottom"].set_visible(True)
ax.spines["left"].set_visible(True)
plt.xticks([y+1 for y in range(len(data))], 8*['x'])
# raised title
#plt.text(2, 1, 'Modified',
# horizontalalignment='center',
# fontsize=18)
plt.tight_layout()
plt.show()
boxplot_modified(df.values)
i kiedy zrobić zwykły działka bez dostosowanie, problem nadal występuje:
def boxplot(data):
fig = plt.figure(figsize=(8,6))
ax = plt.subplot(111)
bplot = plt.boxplot(data,
notch=True, # notch shape
vert=True, # vertical box aligmnent
sym='ko', # red circle for outliers
patch_artist=True, # fill with color
)
plt.show()
boxplot(df.values)
Czy możesz podać samodzielny przykład zawierający dane? –
Wygląda to na kolejną regresję boxplot ... możesz a) zrobić samodzielny przykład b) stworzyć problem na githubie? – tacaswell
Zarówno gotowe! Oto przykład [samodzielny] (http://nbviewer.ipython.org/github/rasbt/matplotlib-gallery/blob/master/bugreport/boxplot_notch/boxplot_notch.ipynb) i tutaj [problem na github] (https) : //github.com/matplotlib/matplotlib/issues/3631) – Sebastian