Python matplotlib.pyplot错误

时间:2017-08-15 19:52:40

标签: python python-3.x matplotlib

我正在尝试运行以下代码:

#!/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()

我收到附图中的错误

enter image description here

0 个答案:

没有答案