Matplotlib cheatsheet

Higher resolution plots

      f, axs = plt.subplots(1, 2, figsize=(12,3), dpi=300)
      

Hide some of the axes

      axs[0].spines['right'].set_visible(False)
      axs[0].spines['top'].set_visible(False)
      

Set spacing between the plot and the title

      axs[0].set_title('aaa', fontfamily = 'Arial Black', pad = 20) 
      

Hide the tick marks

      axs[0].tick_params(left=False, bottom=False)
      

Change space between the subplots

      plt.subplots_adjust(wspace=0.4, hspace=0.4)
      

Make sure nothing gets cut during saving

      plt.savefig('img.png', bbox_inches = 'tight')
      

14 Mar 2022