Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.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
在matplotlib python中未获得预期结果_Python_Matplotlib - Fatal编程技术网

在matplotlib python中未获得预期结果

在matplotlib python中未获得预期结果,python,matplotlib,Python,Matplotlib,在y轴上没有得到期望值,我的代码中有问题吗? , 导入matplotlib.pyplot作为plt x_值=列表(范围(11001)) y_值=[x**2代表x中的x_值] plt.散射(x_值,y_值,s=40) plt.标题(“散乱的正方形2”,字体大小=15) plt.xlabel(“值”,fontsize=14) plt.ylabel(“值的平方”,fontsize=15) #设置每个轴的范围。 plt.轴([01100,01100000]) plt.show() 未在y轴上获取预期

在y轴上没有得到期望值,我的代码中有问题吗? ,

导入matplotlib.pyplot作为plt
x_值=列表(范围(11001))
y_值=[x**2代表x中的x_值]
plt.散射(x_值,y_值,s=40)
plt.标题(“散乱的正方形2”,字体大小=15)
plt.xlabel(“值”,fontsize=14)
plt.ylabel(“值的平方”,fontsize=15)
#设置每个轴的范围。
plt.轴([01100,01100000])
plt.show()

未在y轴上获取预期值,代码中是否存在任何问题?

使用
plt.ticklabel\u格式(style='plain')
禁用科学记数法

import matplotlib.pyplot as plt
x_values = list(range(1,1001))

y_values = [ x**2 for x in x_values]
plt.scatter(x_values,y_values,s=40)
plt.ticklabel_format(style='plain') #< ---- here
plt.title("scattered squares 2",fontsize=15)
plt.xlabel("value",fontsize=14)
plt.ylabel("square of value",fontsize=15)
# Set the range for each axis.
plt.axis([0,1100,0,1100000])

plt.show()
导入matplotlib.pyplot作为plt
x_值=列表(范围(11001))
y_值=[x**2代表x中的x_值]
plt.散射(x_值,y_值,s=40)
plt.ticklab_格式(style='plain')这里
plt.标题(“散乱的正方形2”,字体大小=15)
plt.xlabel(“值”,fontsize=14)
plt.ylabel(“值的平方”,fontsize=15)
#设置每个轴的范围。
plt.轴([01100,01100000])
plt.show()


使用绘图更清晰:

import matplotlib.pyplot as plt
x_values = list(range(1,1001))

y_values = [ x**2 for x in x_values]

plt.ticklabel_format(style='plain') #< ---- here
plt.title("scattered squares 2",fontsize=15)
plt.xlabel("value",fontsize=14)
plt.ylabel("square of value",fontsize=15)
# Set the range for each axis.
plt.plot(x_values,y_values)
plt.show()
导入matplotlib.pyplot作为plt
x_值=列表(范围(11001))
y_值=[x**2代表x中的x_值]
plt.ticklab_格式(style='plain')这里
plt.标题(“散乱的正方形2”,字体大小=15)
plt.xlabel(“值”,fontsize=14)
plt.ylabel(“值的平方”,fontsize=15)
#设置每个轴的范围。
plt.绘图(x_值、y_值)
plt.show()
输出:


您希望看到什么?添加了图像。你可以看到now@py_kumar可能会将matplotlib升级到最新版本。我没有得到科学的符号。现在工作,这是每个代码都需要的吗?plt用于当前绘图,所以我想是的,但我认为有一种方法可以使每个绘图都不重复使用相同的符号。为什么这被否决了?使用plot使图形看起来比axis更清晰我没有投反对票,但我想有人认为这个答案与我的答案相似,这就是为什么。@Pygirl它很相似,但使用axis使图形看起来更厚,普洛特让它看起来更漂亮cleaner@Pygirl感谢重播:)如果问题是通过其他答案回答的,则可以通过评论向其他答案提出改进建议:)