我正在尝试运行以下代码:
#!/usr/bin/python3
# squares.py: page 324-326
import matplotlib.pyplot as plt
squares = []
input_value = []
for x in range(-10, 11):
input_value.append(x)
n = x ** 2
squares.append(n)
plt.plot(input_value, squares, linewidth=1)
plt.title("Square Numbers", fontsize=14) # Set chart title
plt.xlabel("Value", fontsize=12) # Set label x-axis
plt.ylabel("Square of Value", fontsize=12) # Set label y-axis
plt.grid(True) # Add grid to graph
plt.rc('grid', linestyle="-", color='black')
plt.tick_params(axis='both', labelsize=14) # Set size of tick labels
plt.show()
我收到附图中的错误