Bikash Santra
Indian Statistical Institute, Kolkata
import matplotlib # OR, from matplotlib import pyplot as plt
import numpy as np
print(matplotlib.__version__)
3.3.4
# The inline is important for the notebook, so that plots are displayed in the notebook and not in a new window.
import matplotlib.pyplot as plt
x = np.arange(-100,100.1,0.5) # Return evenly spaced values within a given interval
print(x, x.shape)
[-100. -99.5 -99. -98.5 -98. -97.5 -97. -96.5 -96. -95.5 -95. -94.5 -94. -93.5 -93. -92.5 -92. -91.5 -91. -90.5 -90. -89.5 -89. -88.5 -88. -87.5 -87. -86.5 -86. -85.5 -85. -84.5 -84. -83.5 -83. -82.5 -82. -81.5 -81. -80.5 -80. -79.5 -79. -78.5 -78. -77.5 -77. -76.5 -76. -75.5 -75. -74.5 -74. -73.5 -73. -72.5 -72. -71.5 -71. -70.5 -70. -69.5 -69. -68.5 -68. -67.5 -67. -66.5 -66. -65.5 -65. -64.5 -64. -63.5 -63. -62.5 -62. -61.5 -61. -60.5 -60. -59.5 -59. -58.5 -58. -57.5 -57. -56.5 -56. -55.5 -55. -54.5 -54. -53.5 -53. -52.5 -52. -51.5 -51. -50.5 -50. -49.5 -49. -48.5 -48. -47.5 -47. -46.5 -46. -45.5 -45. -44.5 -44. -43.5 -43. -42.5 -42. -41.5 -41. -40.5 -40. -39.5 -39. -38.5 -38. -37.5 -37. -36.5 -36. -35.5 -35. -34.5 -34. -33.5 -33. -32.5 -32. -31.5 -31. -30.5 -30. -29.5 -29. -28.5 -28. -27.5 -27. -26.5 -26. -25.5 -25. -24.5 -24. -23.5 -23. -22.5 -22. -21.5 -21. -20.5 -20. -19.5 -19. -18.5 -18. -17.5 -17. -16.5 -16. -15.5 -15. -14.5 -14. -13.5 -13. -12.5 -12. -11.5 -11. -10.5 -10. -9.5 -9. -8.5 -8. -7.5 -7. -6.5 -6. -5.5 -5. -4.5 -4. -3.5 -3. -2.5 -2. -1.5 -1. -0.5 0. 0.5 1. 1.5 2. 2.5 3. 3.5 4. 4.5 5. 5.5 6. 6.5 7. 7.5 8. 8.5 9. 9.5 10. 10.5 11. 11.5 12. 12.5 13. 13.5 14. 14.5 15. 15.5 16. 16.5 17. 17.5 18. 18.5 19. 19.5 20. 20.5 21. 21.5 22. 22.5 23. 23.5 24. 24.5 25. 25.5 26. 26.5 27. 27.5 28. 28.5 29. 29.5 30. 30.5 31. 31.5 32. 32.5 33. 33.5 34. 34.5 35. 35.5 36. 36.5 37. 37.5 38. 38.5 39. 39.5 40. 40.5 41. 41.5 42. 42.5 43. 43.5 44. 44.5 45. 45.5 46. 46.5 47. 47.5 48. 48.5 49. 49.5 50. 50.5 51. 51.5 52. 52.5 53. 53.5 54. 54.5 55. 55.5 56. 56.5 57. 57.5 58. 58.5 59. 59.5 60. 60.5 61. 61.5 62. 62.5 63. 63.5 64. 64.5 65. 65.5 66. 66.5 67. 67.5 68. 68.5 69. 69.5 70. 70.5 71. 71.5 72. 72.5 73. 73.5 74. 74.5 75. 75.5 76. 76.5 77. 77.5 78. 78.5 79. 79.5 80. 80.5 81. 81.5 82. 82.5 83. 83.5 84. 84.5 85. 85.5 86. 86.5 87. 87.5 88. 88.5 89. 89.5 90. 90.5 91. 91.5 92. 92.5 93. 93.5 94. 94.5 95. 95.5 96. 96.5 97. 97.5 98. 98.5 99. 99.5 100. ] (401,)
y = x**2
print(y)
[1.00000e+04 9.90025e+03 9.80100e+03 9.70225e+03 9.60400e+03 9.50625e+03 9.40900e+03 9.31225e+03 9.21600e+03 9.12025e+03 9.02500e+03 8.93025e+03 8.83600e+03 8.74225e+03 8.64900e+03 8.55625e+03 8.46400e+03 8.37225e+03 8.28100e+03 8.19025e+03 8.10000e+03 8.01025e+03 7.92100e+03 7.83225e+03 7.74400e+03 7.65625e+03 7.56900e+03 7.48225e+03 7.39600e+03 7.31025e+03 7.22500e+03 7.14025e+03 7.05600e+03 6.97225e+03 6.88900e+03 6.80625e+03 6.72400e+03 6.64225e+03 6.56100e+03 6.48025e+03 6.40000e+03 6.32025e+03 6.24100e+03 6.16225e+03 6.08400e+03 6.00625e+03 5.92900e+03 5.85225e+03 5.77600e+03 5.70025e+03 5.62500e+03 5.55025e+03 5.47600e+03 5.40225e+03 5.32900e+03 5.25625e+03 5.18400e+03 5.11225e+03 5.04100e+03 4.97025e+03 4.90000e+03 4.83025e+03 4.76100e+03 4.69225e+03 4.62400e+03 4.55625e+03 4.48900e+03 4.42225e+03 4.35600e+03 4.29025e+03 4.22500e+03 4.16025e+03 4.09600e+03 4.03225e+03 3.96900e+03 3.90625e+03 3.84400e+03 3.78225e+03 3.72100e+03 3.66025e+03 3.60000e+03 3.54025e+03 3.48100e+03 3.42225e+03 3.36400e+03 3.30625e+03 3.24900e+03 3.19225e+03 3.13600e+03 3.08025e+03 3.02500e+03 2.97025e+03 2.91600e+03 2.86225e+03 2.80900e+03 2.75625e+03 2.70400e+03 2.65225e+03 2.60100e+03 2.55025e+03 2.50000e+03 2.45025e+03 2.40100e+03 2.35225e+03 2.30400e+03 2.25625e+03 2.20900e+03 2.16225e+03 2.11600e+03 2.07025e+03 2.02500e+03 1.98025e+03 1.93600e+03 1.89225e+03 1.84900e+03 1.80625e+03 1.76400e+03 1.72225e+03 1.68100e+03 1.64025e+03 1.60000e+03 1.56025e+03 1.52100e+03 1.48225e+03 1.44400e+03 1.40625e+03 1.36900e+03 1.33225e+03 1.29600e+03 1.26025e+03 1.22500e+03 1.19025e+03 1.15600e+03 1.12225e+03 1.08900e+03 1.05625e+03 1.02400e+03 9.92250e+02 9.61000e+02 9.30250e+02 9.00000e+02 8.70250e+02 8.41000e+02 8.12250e+02 7.84000e+02 7.56250e+02 7.29000e+02 7.02250e+02 6.76000e+02 6.50250e+02 6.25000e+02 6.00250e+02 5.76000e+02 5.52250e+02 5.29000e+02 5.06250e+02 4.84000e+02 4.62250e+02 4.41000e+02 4.20250e+02 4.00000e+02 3.80250e+02 3.61000e+02 3.42250e+02 3.24000e+02 3.06250e+02 2.89000e+02 2.72250e+02 2.56000e+02 2.40250e+02 2.25000e+02 2.10250e+02 1.96000e+02 1.82250e+02 1.69000e+02 1.56250e+02 1.44000e+02 1.32250e+02 1.21000e+02 1.10250e+02 1.00000e+02 9.02500e+01 8.10000e+01 7.22500e+01 6.40000e+01 5.62500e+01 4.90000e+01 4.22500e+01 3.60000e+01 3.02500e+01 2.50000e+01 2.02500e+01 1.60000e+01 1.22500e+01 9.00000e+00 6.25000e+00 4.00000e+00 2.25000e+00 1.00000e+00 2.50000e-01 0.00000e+00 2.50000e-01 1.00000e+00 2.25000e+00 4.00000e+00 6.25000e+00 9.00000e+00 1.22500e+01 1.60000e+01 2.02500e+01 2.50000e+01 3.02500e+01 3.60000e+01 4.22500e+01 4.90000e+01 5.62500e+01 6.40000e+01 7.22500e+01 8.10000e+01 9.02500e+01 1.00000e+02 1.10250e+02 1.21000e+02 1.32250e+02 1.44000e+02 1.56250e+02 1.69000e+02 1.82250e+02 1.96000e+02 2.10250e+02 2.25000e+02 2.40250e+02 2.56000e+02 2.72250e+02 2.89000e+02 3.06250e+02 3.24000e+02 3.42250e+02 3.61000e+02 3.80250e+02 4.00000e+02 4.20250e+02 4.41000e+02 4.62250e+02 4.84000e+02 5.06250e+02 5.29000e+02 5.52250e+02 5.76000e+02 6.00250e+02 6.25000e+02 6.50250e+02 6.76000e+02 7.02250e+02 7.29000e+02 7.56250e+02 7.84000e+02 8.12250e+02 8.41000e+02 8.70250e+02 9.00000e+02 9.30250e+02 9.61000e+02 9.92250e+02 1.02400e+03 1.05625e+03 1.08900e+03 1.12225e+03 1.15600e+03 1.19025e+03 1.22500e+03 1.26025e+03 1.29600e+03 1.33225e+03 1.36900e+03 1.40625e+03 1.44400e+03 1.48225e+03 1.52100e+03 1.56025e+03 1.60000e+03 1.64025e+03 1.68100e+03 1.72225e+03 1.76400e+03 1.80625e+03 1.84900e+03 1.89225e+03 1.93600e+03 1.98025e+03 2.02500e+03 2.07025e+03 2.11600e+03 2.16225e+03 2.20900e+03 2.25625e+03 2.30400e+03 2.35225e+03 2.40100e+03 2.45025e+03 2.50000e+03 2.55025e+03 2.60100e+03 2.65225e+03 2.70400e+03 2.75625e+03 2.80900e+03 2.86225e+03 2.91600e+03 2.97025e+03 3.02500e+03 3.08025e+03 3.13600e+03 3.19225e+03 3.24900e+03 3.30625e+03 3.36400e+03 3.42225e+03 3.48100e+03 3.54025e+03 3.60000e+03 3.66025e+03 3.72100e+03 3.78225e+03 3.84400e+03 3.90625e+03 3.96900e+03 4.03225e+03 4.09600e+03 4.16025e+03 4.22500e+03 4.29025e+03 4.35600e+03 4.42225e+03 4.48900e+03 4.55625e+03 4.62400e+03 4.69225e+03 4.76100e+03 4.83025e+03 4.90000e+03 4.97025e+03 5.04100e+03 5.11225e+03 5.18400e+03 5.25625e+03 5.32900e+03 5.40225e+03 5.47600e+03 5.55025e+03 5.62500e+03 5.70025e+03 5.77600e+03 5.85225e+03 5.92900e+03 6.00625e+03 6.08400e+03 6.16225e+03 6.24100e+03 6.32025e+03 6.40000e+03 6.48025e+03 6.56100e+03 6.64225e+03 6.72400e+03 6.80625e+03 6.88900e+03 6.97225e+03 7.05600e+03 7.14025e+03 7.22500e+03 7.31025e+03 7.39600e+03 7.48225e+03 7.56900e+03 7.65625e+03 7.74400e+03 7.83225e+03 7.92100e+03 8.01025e+03 8.10000e+03 8.19025e+03 8.28100e+03 8.37225e+03 8.46400e+03 8.55625e+03 8.64900e+03 8.74225e+03 8.83600e+03 8.93025e+03 9.02500e+03 9.12025e+03 9.21600e+03 9.31225e+03 9.40900e+03 9.50625e+03 9.60400e+03 9.70225e+03 9.80100e+03 9.90025e+03 1.00000e+04]
plt.plot(x,y)
plt.xlabel('Real number')
plt.ylabel('Squarred values')
plt.show()
# plt.plot(x,y)
# plt.show()
x = np.linspace(0, 3, 20)
print(x, x.shape)
y = np.linspace(0, 9, 20)
print(y)
[0. 0.15789474 0.31578947 0.47368421 0.63157895 0.78947368 0.94736842 1.10526316 1.26315789 1.42105263 1.57894737 1.73684211 1.89473684 2.05263158 2.21052632 2.36842105 2.52631579 2.68421053 2.84210526 3. ] (20,) [0. 0.47368421 0.94736842 1.42105263 1.89473684 2.36842105 2.84210526 3.31578947 3.78947368 4.26315789 4.73684211 5.21052632 5.68421053 6.15789474 6.63157895 7.10526316 7.57894737 8.05263158 8.52631579 9. ]
plt.plot(x, y)
plt.xlabel('X-Axis')
plt.ylabel('Y-Axis')
plt.title('Dummy Plot', fontsize=10)
plt.show()
plt.plot(x, y, '+') # dot plot
plt.show()
X = np.linspace(-np.pi, np.pi, 256, endpoint=False)
print(X)
[-3.14159265 -3.11704896 -3.09250527 -3.06796158 -3.04341788 -3.01887419 -2.9943305 -2.96978681 -2.94524311 -2.92069942 -2.89615573 -2.87161203 -2.84706834 -2.82252465 -2.79798096 -2.77343726 -2.74889357 -2.72434988 -2.69980619 -2.67526249 -2.6507188 -2.62617511 -2.60163142 -2.57708772 -2.55254403 -2.52800034 -2.50345665 -2.47891295 -2.45436926 -2.42982557 -2.40528188 -2.38073818 -2.35619449 -2.3316508 -2.3071071 -2.28256341 -2.25801972 -2.23347603 -2.20893233 -2.18438864 -2.15984495 -2.13530126 -2.11075756 -2.08621387 -2.06167018 -2.03712649 -2.01258279 -1.9880391 -1.96349541 -1.93895172 -1.91440802 -1.88986433 -1.86532064 -1.84077695 -1.81623325 -1.79168956 -1.76714587 -1.74260218 -1.71805848 -1.69351479 -1.6689711 -1.6444274 -1.61988371 -1.59534002 -1.57079633 -1.54625263 -1.52170894 -1.49716525 -1.47262156 -1.44807786 -1.42353417 -1.39899048 -1.37444679 -1.34990309 -1.3253594 -1.30081571 -1.27627202 -1.25172832 -1.22718463 -1.20264094 -1.17809725 -1.15355355 -1.12900986 -1.10446617 -1.07992247 -1.05537878 -1.03083509 -1.0062914 -0.9817477 -0.95720401 -0.93266032 -0.90811663 -0.88357293 -0.85902924 -0.83448555 -0.80994186 -0.78539816 -0.76085447 -0.73631078 -0.71176709 -0.68722339 -0.6626797 -0.63813601 -0.61359232 -0.58904862 -0.56450493 -0.53996124 -0.51541754 -0.49087385 -0.46633016 -0.44178647 -0.41724277 -0.39269908 -0.36815539 -0.3436117 -0.319068 -0.29452431 -0.26998062 -0.24543693 -0.22089323 -0.19634954 -0.17180585 -0.14726216 -0.12271846 -0.09817477 -0.07363108 -0.04908739 -0.02454369 0. 0.02454369 0.04908739 0.07363108 0.09817477 0.12271846 0.14726216 0.17180585 0.19634954 0.22089323 0.24543693 0.26998062 0.29452431 0.319068 0.3436117 0.36815539 0.39269908 0.41724277 0.44178647 0.46633016 0.49087385 0.51541754 0.53996124 0.56450493 0.58904862 0.61359232 0.63813601 0.6626797 0.68722339 0.71176709 0.73631078 0.76085447 0.78539816 0.80994186 0.83448555 0.85902924 0.88357293 0.90811663 0.93266032 0.95720401 0.9817477 1.0062914 1.03083509 1.05537878 1.07992247 1.10446617 1.12900986 1.15355355 1.17809725 1.20264094 1.22718463 1.25172832 1.27627202 1.30081571 1.3253594 1.34990309 1.37444679 1.39899048 1.42353417 1.44807786 1.47262156 1.49716525 1.52170894 1.54625263 1.57079633 1.59534002 1.61988371 1.6444274 1.6689711 1.69351479 1.71805848 1.74260218 1.76714587 1.79168956 1.81623325 1.84077695 1.86532064 1.88986433 1.91440802 1.93895172 1.96349541 1.9880391 2.01258279 2.03712649 2.06167018 2.08621387 2.11075756 2.13530126 2.15984495 2.18438864 2.20893233 2.23347603 2.25801972 2.28256341 2.3071071 2.3316508 2.35619449 2.38073818 2.40528188 2.42982557 2.45436926 2.47891295 2.50345665 2.52800034 2.55254403 2.57708772 2.60163142 2.62617511 2.6507188 2.67526249 2.69980619 2.72434988 2.74889357 2.77343726 2.79798096 2.82252465 2.84706834 2.87161203 2.89615573 2.92069942 2.94524311 2.96978681 2.9943305 3.01887419 3.04341788 3.06796158 3.09250527 3.11704896]
# Using default setting
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C, S = np.cos(X), np.sin(X)
plt.plot(X, C)
plt.plot(X, S)
plt.show()
# Customized
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C, S = np.cos(X), np.sin(X)
#------ Setting figure size -------------
# Create a figure of size 8x6 inches, 80 dots per inch
plt.figure(figsize=(8, 6), dpi=80)
#----- Changing colors and line widths -------
# Plot cosine with a blue continuous line of width 1 (pixels)
plt.plot(X, C, color="blue", linewidth=3.0, linestyle="--")
# Plot sine with a green continuous line of width 1 (pixels)
plt.plot(X, S, color="green", linewidth=1.0, linestyle="-")
# plt.legend(loc='upper left')
#------- Setting limits -------
# Set x limits
plt.xlim(-4.0, 4.0)
# Set y limits
plt.ylim(-1.0, 1.0)
#-------- Setting ticks --------
# Set x ticks
plt.xticks(np.linspace(-4, 4, 9, endpoint=True))
# Set y ticks
plt.yticks(np.linspace(-1, 1, 5, endpoint=True))
#------- Saving figure in drive -------
# Save figure using 72 dots per inch
plt.savefig("exercise_2.png", dpi=72)
# Show result on screen
plt.show()
plt.gcf().canvas.get_supported_filetypes()
{'eps': 'Encapsulated Postscript', 'jpg': 'Joint Photographic Experts Group', 'jpeg': 'Joint Photographic Experts Group', 'pdf': 'Portable Document Format', 'pgf': 'PGF code for LaTeX', 'png': 'Portable Network Graphics', 'ps': 'Postscript', 'raw': 'Raw RGBA bitmap', 'rgba': 'Raw RGBA bitmap', 'svg': 'Scalable Vector Graphics', 'svgz': 'Scalable Vector Graphics', 'tif': 'Tagged Image File Format', 'tiff': 'Tagged Image File Format'}
<Figure size 432x288 with 0 Axes>
# More Customized
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C, S = np.cos(X), np.sin(X)
#------ Setting figure size -------------
# Create a figure of size 8x6 inches, 80 dots per inch
plt.figure(figsize=(8, 6), dpi=80)
#----- Changing colors and line widths ------- Adding a legend ---------
# Plot cosine with a blue continuous line of width 1 (pixels)
plt.plot(X, C, color="blue", linewidth=1.0, linestyle="-", label = "Cosine")
# Plot sine with a green continuous line of width 1 (pixels)
plt.plot(X, S, color="green", linewidth=1.0, linestyle="-", label = "Sine")
plt.legend(loc='upper left')
#------- Setting limits -------
# Set x limits
plt.xlim(-4.0, 4.0)
# Set y limits
plt.ylim(-1.0, 1.0)
#-------- Setting ticks --------
# Set x ticks
plt.xticks(np.linspace(-4, 4, 9, endpoint=True))
# Set y ticks
plt.yticks(np.linspace(-1, 1, 5, endpoint=True))
#-------- Moving spines ----------------
ax = plt.gca() # gca stands for 'get current axis'
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data',0))
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_position(('data',0))
#-------- Annotate some points -------------
t = 2 * np.pi / 3
plt.plot([t, t], [0, np.cos(t)], color='blue', linewidth=2.5, linestyle="--")
plt.scatter([t, ], [np.cos(t), ], 50, color='blue')
plt.annotate(r'$cos(\frac{2\pi}{3})=-\frac{1}{2}$',
xy=(t, np.cos(t)), xycoords='data',
xytext=(-90, -50), textcoords='offset points', fontsize=16,
arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2"))
plt.plot([t, t],[0, np.sin(t)], color='red', linewidth=2.5, linestyle="--")
plt.scatter([t, ],[np.sin(t), ], 50, color='red')
plt.annotate(r'$sin(\frac{2\pi}{3})=\frac{\sqrt{3}}{2}$',
xy=(t, np.sin(t)), xycoords='data',
xytext=(+10, +30), textcoords='offset points', fontsize=16,
arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2"))
#--------- Devil is in the details ------------
for label in ax.get_xticklabels() + ax.get_yticklabels():
label.set_fontsize(16)
label.set_bbox(dict(facecolor='white', edgecolor='None', alpha=0.65))
# Show result on screen
plt.show()
# Add label, title, legends
# Compute the x and y coordinates for points on sine and cosine curves
x = np.arange(0, 3 * np.pi, 0.1)
y_sin = np.sin(x)
y_cos = np.cos(x)
# Plot the points using matplotlib
plt.plot(x, y_sin)
plt.plot(x, y_cos)
plt.xlabel('x axis label')
plt.ylabel('y axis label')
plt.title('Sine and Cosine')
plt.legend(['Sine', 'Cosine'], loc='upper left')
plt.show()
x = np.linspace(0, 10, 100)
print(x,x.shape)
[ 0. 0.1010101 0.2020202 0.3030303 0.4040404 0.50505051 0.60606061 0.70707071 0.80808081 0.90909091 1.01010101 1.11111111 1.21212121 1.31313131 1.41414141 1.51515152 1.61616162 1.71717172 1.81818182 1.91919192 2.02020202 2.12121212 2.22222222 2.32323232 2.42424242 2.52525253 2.62626263 2.72727273 2.82828283 2.92929293 3.03030303 3.13131313 3.23232323 3.33333333 3.43434343 3.53535354 3.63636364 3.73737374 3.83838384 3.93939394 4.04040404 4.14141414 4.24242424 4.34343434 4.44444444 4.54545455 4.64646465 4.74747475 4.84848485 4.94949495 5.05050505 5.15151515 5.25252525 5.35353535 5.45454545 5.55555556 5.65656566 5.75757576 5.85858586 5.95959596 6.06060606 6.16161616 6.26262626 6.36363636 6.46464646 6.56565657 6.66666667 6.76767677 6.86868687 6.96969697 7.07070707 7.17171717 7.27272727 7.37373737 7.47474747 7.57575758 7.67676768 7.77777778 7.87878788 7.97979798 8.08080808 8.18181818 8.28282828 8.38383838 8.48484848 8.58585859 8.68686869 8.78787879 8.88888889 8.98989899 9.09090909 9.19191919 9.29292929 9.39393939 9.49494949 9.5959596 9.6969697 9.7979798 9.8989899 10. ] (100,)
y = np.cos(x)
print(y)
[ 1. 0.99490282 0.97966323 0.95443659 0.91948007 0.87515004 0.8218984 0.76026803 0.69088721 0.61446323 0.53177518 0.44366602 0.35103397 0.25482335 0.15601496 0.0556161 -0.04534973 -0.14585325 -0.24486989 -0.34139023 -0.43443032 -0.52304166 -0.60632092 -0.68341913 -0.75355031 -0.81599952 -0.87013012 -0.91539031 -0.95131866 -0.97754893 -0.9938137 -0.99994717 -0.9958868 -0.981674 -0.95745366 -0.92347268 -0.88007748 -0.82771044 -0.76690542 -0.69828229 -0.6225406 -0.54045251 -0.45285485 -0.36064061 -0.26474988 -0.16616018 -0.06587659 0.03507857 0.13567613 0.23489055 0.33171042 0.4251487 0.51425287 0.59811455 0.67587883 0.74675295 0.8100144 0.86501827 0.91120382 0.94810022 0.97533134 0.99261957 0.99978867 0.99676556 0.98358105 0.96036956 0.9273677 0.88491192 0.83343502 0.77346177 0.70560358 0.63055219 0.54907273 0.46199582 0.37020915 0.27464844 0.17628785 0.07613012 -0.0248037 -0.12548467 -0.2248864 -0.32199555 -0.41582217 -0.50540974 -0.58984498 -0.66826712 -0.7398767 -0.8039437 -0.859815 -0.90692104 -0.94478159 -0.97301068 -0.99132055 -0.99952453 -0.99753899 -0.98538417 -0.96318398 -0.93116473 -0.88965286 -0.83907153]
plt.plot(x, y)
plt.show()
x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.figure(figsize=(8,6), dpi=70)
[line_handle] = plt.plot(x, y, c='g', linewidth=4, label='sine')
y2 = np.cos(x)
[line_handle2] = plt.plot(x, y2, c='#ffadcd', linewidth=2, label='cos')
plt.legend(handles=[line_handle, line_handle2], fontsize=30, loc='lower right', shadow=True)
plt.xlabel('x axis', fontsize=30)
plt.ylabel('y axis', fontsize=30)
plt.title('A plot', fontsize=30)
plt.xticks(fontsize=20)
plt.yticks([-1, -0.5, 0, 0.5, 1], [-1, -0.5, 0, 0.5, 1], fontsize=20)
plt.show()
a) Matpltlob documentation gallery
b) https://www.scipy-lectures.org/intro/matplotlib/index.html
c) https://www.scipy-lectures.org/packages/3d_plotting/index.html
d) https://github.com/kuleshov/cs228-material/blob/master/tutorials/python/cs228-python-tutorial.ipynb