Advertisement
NLinker

Matplotlib: black background

Mar 18th, 2018
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.61 KB | None | 0 0
  1. matplotlib.rcParams.update({'font.size': 12})
  2. fig = matplotlib.pyplot.figure(figsize=(5,5),dpi=300,facecolor='black')
  3. fig.subplots_adjust(wspace=.05,left=.01,bottom=.01)
  4. ax = fig.add_subplot(1,1,1,axisbg='k')
  5.  
  6. ax.spines['top'].set_visible(False)
  7. ax.spines['right'].set_visible(False)
  8. ax.spines['bottom'].set_linewidth(0.5)
  9. ax.spines['left'].set_linewidth(0.5)
  10. ax.spines['bottom'].set_color('white')
  11. ax.spines['left'].set_color('white')
  12.  
  13. ax.title.set_color('white')
  14. ax.yaxis.label.set_color('white')
  15. ax.xaxis.label.set_color('white')
  16. ax.tick_params(axis='x', colors='white')
  17. ax.tick_params(axis='y', colors='white')
  18.  
  19. ax.tick_params(axis='both', direction='in')
  20. ax.get_xaxis().tick_bottom()
  21. ax.get_yaxis().tick_left()
  22.  
  23. ax.set_xlabel('X-Axis Label Here')
  24. ax.set_ylabel('Y-Axis Label Here')
  25. ax.set_title('Title Here')
  26. ax.plot(range(10),range(10),'.-',color='yellow', linewidth=2, markersize=12)
  27.  
  28. matplotlib.pyplot.savefig("dark.png", bbox_inches='tight', facecolor=fig.get_facecolor(), transparent=True)
  29.  
  30. ## from hw5
  31.  
  32. ax = data['SeriousDlqin2yrs'].hist(orientation='horizontal', color='red')
  33.  
  34. ax.spines['bottom'].set_color('white')
  35. ax.spines['left'].set_color('white')
  36. ax.title.set_color('white')
  37. ax.yaxis.label.set_color('white')
  38. ax.xaxis.label.set_color('white')
  39. ax.tick_params(axis='x', colors='white')
  40. ax.tick_params(axis='y', colors='white')
  41. ax.set_facecolor((0.01, 0.01, 0.01))
  42. ax.grid(color='white')
  43.  
  44. ax.set_xlabel("number_of_observations")
  45. ax.set_ylabel("unique_value")
  46. ax.set_title("Target distribution")
  47.  
  48. print('Distribution of target:')
  49. data['SeriousDlqin2yrs'].value_counts() / data.shape[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement