如何去除Matplotlib图表上的异常白色标记?
图表上的白色标记无法消除
试了各种办法,图表上这个白色标记就是消不掉。我已经关掉了刻度(ticks)、刻度标签(tick labels)、网格线(gridlines)这些设置,完全没用。

下面是生成图表的完整代码,如果知道问题出在哪段,我可以提供简化版本:
import matplotlib.pyplot as plt plt.style.use('dark_background') my_figure = plt.figure(**{'dpi': 100.0, 'edgecolor': 'black', 'facecolor': 'black', 'figsize': (8.0, 6.0), 'linewidth': 1.0}) my_figure.suptitle(**{'fontsize': 'x-large', 'fontweight': 'semibold', 'horizontalalignment': 'center', 't': 'Boxplot', 'verticalalignment': 'top'}) my_figure.supxlabel(**{'fontsize': 'large', 'fontweight': 'normal', 'horizontalalignment': 'center', 't': 'values', 'verticalalignment': 'bottom'}) my_figure.supylabel(**{'fontsize': 'large', 'fontweight': 'normal', 'horizontalalignment': 'center', 't': 'values', 'verticalalignment': 'bottom'}) axes_dictionary = my_figure.subplot_mosaic(mosaic=[['boxplot'], ['histogram'], ['histogram'], ['histogram']] , gridspec_kw={'wspace': 0.0, 'hspace': 0.0}) axes_dictionary['boxplot'].bxp(**{'boxprops': {'alpha': 0.8, 'facecolor': 'C0'}, 'bxpstats': [{'label': 'obs5', 'mean': 74.00224000000001, 'med': 74.004, 'q1': 73.996, 'q3': 74.009, 'whishi': 73.984, 'whislo': 74.014}], 'capprops': {'color': 'C0'}, 'patch_artist': True, 'positions': [0], 'showfliers': False, 'vert': False, 'whiskerprops': {'color': 'C0'}, 'widths': 0.5, 'zorder': 1.0}) axes_dictionary['histogram'].hist(**{'align': 'mid', 'alpha': 0.6, 'bins': [73.98100280761719, 73.98699951171875, 73.99299621582031, 73.9990005493164, 74.00499725341797, 74.01100158691406, 74.017], 'color': 'C0', 'histtype': 'bar', 'label': 'obs5', 'orientation': 'vertical', 'weights': [1, 3, 5, 6, 6, 4], 'x': [73.98100280761719, 73.98699951171875, 73.99299621582031, 73.9990005493164, 74.00499725341797, 74.01100158691406], 'zorder': 0.0}) axes_dictionary['histogram'].set_xticks( ticks=[73.98100280761719, 73.98699951171875, 73.99299621582031, 73.9990005493164, 74.00499725341797, 74.01100158691406, 74.017]) axes_dictionary['histogram'].set_xticklabels( labels=[73.98100280761719, 73.98699951171875, 73.99299621582031, 73.9990005493164, 74.00499725341797, 74.01100158691406, 74.017]) axes_dictionary['histogram'].set_yticks(ticks=axes_dictionary['histogram'].get_yticks()) axes_dictionary['histogram'].set_yticklabels(labels=['', '1', '2', '3', '4', '5', '6', '7']) axes_dictionary['boxplot'].set_xlim(**{'left': 73.97920303344726, 'right': 74.01879806518555}) axes_dictionary['boxplot'].tick_params(**{'labelbottom': False, 'labelleft': False, 'labelright': False, 'labeltop': False}) axes_dictionary['boxplot'].spines['left'].set_visible(False) axes_dictionary['boxplot'].spines['bottom'].set_visible(True) axes_dictionary['boxplot'].spines['top'].set_visible(False) axes_dictionary['boxplot'].spines['right'].set_visible(False) axes_dictionary['boxplot'].tick_params(**{'axis': 'x', 'bottom': False, 'color': 'white', 'direction': 'inout', 'length': 3.0, 'pad': 7.0, 'top': False, 'which': 'major', 'width': 1.0, 'zorder': 1.0}) axes_dictionary['boxplot'].tick_params(**{'axis': 'x', 'bottom': False, 'color': 'white', 'direction': 'inout', 'length': 5.0, 'pad': 4.0, 'top': False, 'which': 'minor', 'width': 5.0, 'zorder': 1.0}) axes_dictionary['boxplot'].tick_params(**{'axis': 'y', 'color': 'white', 'direction': 'out', 'left': False, 'length': 3.0, 'pad': 7.0, 'right': False, 'which': 'major', 'width': 1.0, 'zorder': 1.0}) axes_dictionary['boxplot'].tick_params(**{'axis': 'y', 'color': 'white', 'direction': 'inout', 'left': False, 'length': 2.0, 'pad': 4.0, 'right': False, 'which': 'minor', 'width': 1.0, 'zorder': 1.0}) axes_dictionary['boxplot'].grid(**{'axis': 'x', 'visible': False, 'which': 'major'}) axes_dictionary['boxplot'].grid(**{'axis': 'x', 'visible': False, 'which': 'minor'}) axes_dictionary['boxplot'].grid(**{'axis': 'y', 'visible': False, 'which': 'major'}) axes_dictionary['boxplot'].tick_params(**{'axis': 'y', 'labelbottom': True, 'which': 'major'}) axes_dictionary['histogram'].spines['left'].set_visible(False) axes_dictionary['histogram'].spines['bottom'].set_visible(True) axes_dictionary['histogram'].spines['top'].set_visible(False) axes_dictionary['histogram'].spines['right'].set_visible(False) axes_dictionary['histogram'].legend('', frameon=False) axes_dictionary['histogram'].tick_params(**{'axis': 'x', 'bottom': True, 'color': 'white', 'direction': 'inout', 'length': 3.0, 'pad': 7.0, 'top': False, 'which': 'major', 'width': 1.0, 'zorder': 1.0}) axes_dictionary['histogram'].tick_params(**{'axis': 'x', 'bottom': False, 'color': 'white', 'direction': 'inout', 'length': 5.0, 'pad': 4.0, 'top': False, 'which': 'minor', 'width': 5.0, 'zorder': 1.0}) axes_dictionary['histogram'].tick_params(**{'axis': 'y', 'color': 'white', 'direction': 'out', 'left': False, 'length': 3.0, 'pad': 7.0, 'right': False, 'which': 'major', 'width': 1.0, 'zorder': 1.0}) axes_dictionary['histogram'].tick_params(**{'axis': 'y', 'color': 'white', 'direction': 'inout', 'left': False, 'length': 2.0, 'pad': 4.0, 'right': False, 'which': 'minor', 'width': 1.0, 'zorder': 1.0}) axes_dictionary['histogram'].grid(**{'axis': 'x', 'visible': False, 'which': 'major'}) axes_dictionary['histogram'].grid(**{'axis': 'x', 'visible': False, 'which': 'minor'}) axes_dictionary['histogram'].grid(**{'axis': 'y', 'visible': False, 'which': 'major'}) axes_dictionary['histogram'].tick_params(**{'axis': 'x', 'labelbottom': True, 'which': 'major'}) axes_dictionary['histogram'].tick_params(**{'axis': 'y', 'labelbottom': True, 'which': 'major'}) plt.show()
内容的提问来源于stack exchange,提问作者Python_Learner
相关产品推荐
相关产品推荐

