Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python matplotlib绘图不显示_Python_Python 3.x_Matplotlib_Anaconda - Fatal编程技术网

Python matplotlib绘图不显示

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 =

我将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 = 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")

谢谢我将把它标记为答案。由于积分不足,无法投票。谢谢。我将把它标记为答案。由于分数不足,无法进行投票。