matplotlib

How to get rid of mark on chart?


This mark on my chart persists no matter what I try to make it go away. I've tried turning off ticks, tick labels, gridlines, and many other things with no luck.

chart with a pixel, unexplainably, white

Full code for chart creation included, if I knew exactly what section of code was causing it I would include more simplified code.

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()

Solution

  • I think this is just part of the bottom spine of the boxplot axes showing up. For me it goes away with a one-line change:

    axes_dictionary['boxplot'].spines['bottom'].set_visible(False)
    

    enter image description here