Python matplotlib绘图不显示
我将PythonV3.6与pycharm和anaconda一起使用。我试着运行下面的代码来绘制一个简单的正弦波Python matplotlib绘图不显示,python,python-3.x,matplotlib,anaconda,Python,Python 3.x,Matplotlib,Anaconda,我将PythonV3.6与pycharm和anaconda一起使用。我试着运行下面的代码来绘制一个简单的正弦波 import numpy as np import matplotlib.pyplot as plt # Generate a sequence of numbers from -10 to 10 with 100 steps in between x = np.linspace(-10, 10, 100) # Create a second array using sine y =
import numpy as np
import matplotlib.pyplot as plt
# Generate a sequence of numbers from -10 to 10 with 100 steps in between
x = np.linspace(-10, 10, 100)
# Create a second array using sine
y = np.sin(x)
# The plot function makes a line chart of one array against another
plt.plot(x, y, marker="x")
pass
代码运行平稳,没有错误,但没有显示绘图。如何使绘图显示?最后缺少
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# Generate a sequence of numbers from -10 to 10 with 100 steps in between
x = np.linspace(-10, 10, 100)
# Create a second array using sine
y = np.sin(x)
# The plot function makes a line chart of one array against another
plt.plot(x, y, marker="x")
plt.show()
pass
或者,如果要将其保存到文件中
plt.savefig("my_file.png")
最后缺少了
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# Generate a sequence of numbers from -10 to 10 with 100 steps in between
x = np.linspace(-10, 10, 100)
# Create a second array using sine
y = np.sin(x)
# The plot function makes a line chart of one array against another
plt.plot(x, y, marker="x")
plt.show()
pass
或者,如果要将其保存到文件中
plt.savefig("my_file.png")
谢谢我将把它标记为答案。由于积分不足,无法投票。谢谢。我将把它标记为答案。由于分数不足,无法进行投票。