import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from platform import python_version
python_version(), np.__version__,matplotlib.__version__
('3.8.10', '1.21.2', '3.4.3')
import matplotlib.pyplot as plt
plt.clf()
height = 5
plt.axhline(y=height)
plt.show()
import matplotlib.pyplot as plt
plt.clf()
x_level = 5
plt.axvline(x=x_level)
plt.show()
import matplotlib.pyplot as plt
plt.clf()
days = ['sun','mon','tue','wed','thu','fri','sat']
values = [1 , 4 , 4 , 8 , 3 , 4 , 3 ]
# plotting a bar just for comparison
plt.bar(days, values)
plt.axvline('thu', color='red')
plt.show()
import matplotlib.pyplot as plt
import numpy as np
plt.clf()
xs = np.random.uniform(0,100,100)
ys = np.random.uniform(0,10,100)
# just to populate the plot
plt.scatter(xs,ys,s=0.6)
# angle of 45 degrees means a slope of 1 (relatively)
slope = (ys.max() - ys.min()) / (xs.max() - xs.min())
plt.axline((1,2),slope=slope)
plt.plot(1,2,'bo')
plt.annotate("(1,2)",(1,2),xytext=(0.05,0.15), textcoords='axes fraction')
plt.show()
import matplotlib.pyplot as plt
plt.clf()
plt.axline((1,2),(5,7))
plt.plot(1,2,'bo')
plt.plot(5,7,'bo')
plt.annotate("(1,2)",(1,2),xytext=(-10,10),textcoords='offset points')
plt.annotate("(5,7)",(5,7),xytext=(-10,-15),textcoords='offset points')
plt.xlim(0,10)
plt.ylim(0,10)
plt.show()
import matplotlib.pyplot as plt
plt.clf()
plt.axhline(y=5,linestyle='dotted')
plt.show()
import matplotlib.pyplot as plt
plt.clf()
plt.axvline(x=5,linestyle='dashed')
plt.show()