from matplotlib import pyplot as plt
import numpy as np
# with a dark mode theme
#from jupyterthemes import jtplot
#jtplot.style(theme='oceans16')
def myplot(xs=(1,2,3), ys=(4,3,7), a=1.0, b=0.0):
""" Make a scatterplot of points xs=[x0,x1,...] and ys=[y0,y1,..]
and a line (a*x + b) . """
plt.figure(dpi=220, figsize=(5,3)) # dots-per-inch; size in inches
plt.xlabel('x'); plt.ylabel('y')
# label is for adding a legend if more than one set of data on plot
plt.scatter(xs, ys, s=2, c='blue', label='scatter') # s=size, c=color
#plt.semilogy(xs, ys, s=2, c='blue', label='scatter') # s=size, c=color
#x_line = (xlo, xhi) = (min(xs), max(xs))
#y_line = (a*xlo+b, a*xhi+b)
#plt.plot(x_line, y_line, color='green', linewidth=1.0, label=f'y={a}x+{b}')
x = list(range(2,50))
y = [
2.0,
2.0,
2.0,
2.0,
1.96875,
1.9047619047619047,
1.825,
1.7442922374429224,
1.6701570680628273,
1.6050156739811912,
1.548828125,
1.5006305170239596,
1.4592436974789915,
1.4235531241002015,
1.3925970873786409,
1.3655773420479302,
1.3418421612422888,
1.320862396956246,
1.3022083533365338,
1.2855299539170506,
1.2705405792945226,
1.2570042039330755,
1.2447252648590412,
1.2335407086827157,
1.2233137444083853,
1.213928921392892,
1.205288234367617,
1.1973080252862673,
1.189916505225245,
1.1830517608076268,
1.1766601411071484,
1.1706949449191806,
1.1651153464615125,
1.1598855113945148,
1.1549738656004664,
1.150352487243748,
1.1459965988527006,
1.1418841409729286,
1.137995412679211,
1.1343127671526998,
1.1308203528224636,
1.1275038923795517,
1.1243504934066895,
1.1213484855104474,
1.1184872797587266,
1.1157572469634582,
1.1131496119441644,
1.1106563613916796
]
# plot those values and superimpose a line
myplot(x, y)
plt.ylim(0.75, 2.25)
plt.xlim(0.0, 52.0)
#plt.yscale("log") # doesn't help identify the shape
# and put a few other things on the plot too
plt.title('')
plt.plot((2,50), (1,1), c='red', label='red')
#plt.legend()
# don't return a value from this cell
None
Are we having fun yet?