Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Python
Posted by: alphaharris
Added: Oct 24, 2018 5:52 PM
Views: 6
high contrast line graph with matplotlib
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import matplotlib as mpl
  4.  
  5. x = np.linspace(0,200,100)
  6. y1 = x*2
  7. y2 = x*3
  8. y3 = x*4
  9. y4 = x*5
  10.  
  11. mpl.rcParams['lines.linewidth'] = 2
  12.  
  13. plt.plot(x,y1,label = '2x', c='0') # Black solid line
  14. plt.plot(x,y2,label = '3x', c='0.2', ls='--') # Dark grey dashed line
  15. plt.plot(x,y3,label = '4x', c='0.4', ls='-.') # Grey dash-dot line
  16. plt.plot(x,y4,label = '5x', c='0.6', ls=':') # Light grey dotted line
  17.  
  18. plt.legend()
  19. plt.show()