का उपयोग करते समय matplotlibs बॉक्सप्लॉट का अजीब व्यवहार matplotlib
के boxplot
फ़ंक्शन में कुछ अजीब व्यवहार का सामना कर रहा हूं जब मैं "notch
" आकार का उपयोग कर रहा हूं। मैं कुछ कोड का उपयोग कर रहा हूं जिसे मैंने कुछ समय पहले लिखा है और उन मुद्दों को कभी नहीं मिला - मैं सोच रहा हूं कि समस्या क्या है। कोई विचार?पायदान आकार
जब मैं बारी पायदान आकार इसे बंद कर लग रहा है, हालांकि सामान्य
इस कोड होगा:
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)
और जब मैं बिना एक सादे साजिश बनाने के अनुकूलन, समस्या अभी भी होती है:
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)
क्या आप डेटा सहित स्वयं निहित उदाहरण प्रदान कर सकते हैं? –
यह एक और बॉक्सप्लॉट रिग्रेशन जैसा दिखता है ... क्या आप ए) एक आत्मनिर्भर उदाहरण बना सकते हैं b) github पर कोई समस्या बनाएं? – tacaswell
दोनों ने किया! यहां एक [स्वयं निहित उदाहरण] है (http://nbviewer.ipython.org/github/rasbt/matplotlib-gallery/blob/master/bugreport/boxplot_notch/boxplot_notch.ipynb) और यहां [github पर समस्या] (https : //github.com/matplotlib/matplotlib/issues/3631) – Sebastian