MCS 275 Spring 2023 worksheet 11 Q1

Created Diff never expires
11 刪除
總計
刪除
單詞
總計
刪除
要繼續使用此功能,請升級到
Diffchecker logo
Diffchecker Pro
22
11 新增
總計
新增
單詞
總計
新增
要繼續使用此功能,請升級到
Diffchecker logo
Diffchecker Pro
22
plt.figure(figsize=(8,6),dpi=120)
fig, ax = plt.subplots(figsize=(8,6),dpi=120)


# 50 sample points
# 50 sample points
x = np.linspace(1, 20, 50)
x = np.linspace(1, 20, 50)


# Plot each function
# Plot each function
plt.plot(x, 100*np.log(x), color="black", linewidth=1, linestyle=":", label="100*log(x)") # thin, dotted black line
ax.plot(x, 100*np.log(x), color="black", linewidth=1, linestyle=":", label="100*log(x)") # thin, dotted black line
plt.plot(x, 15*x, color="darkblue", marker=".", label="15*x") # dark blue, solid line AND dots
ax.plot(x, 15*x, color="darkblue", marker=".", label="15*x") # dark blue, solid line AND dots
plt.plot(x, 10*x*np.log(x), color="orange", label="10*x*log(x)") # orange, solid line
ax.plot(x, 10*x*np.log(x), color="orange", label="10*x*log(x)") # orange, solid line
plt.plot(x, x**2, color="red", linewidth=5, label="x^2") # red, thicker line
ax.plot(x, x**2, color="red", linewidth=5, label="x^2") # red, thicker line


# Labels, title, legend
# Labels, title, legend
plt.xlabel("x")
ax.set_xlabel("x")
plt.ylabel("Instructions executed")
ax.set_ylabel("Instructions executed")
plt.title("Several functions")
ax.set_title("Several functions")
plt.legend()
ax.legend()


# Limits of axes
# Limits of axes
plt.xlim(1,20)
ax.set_xlim(1, 20)
plt.ylim(0,600)
ax.set_ylim(0, 600)


plt.show()
plt.show()