我有这个列表,其中x和y坐标的区间为[-2,2].但是当我绘制列表时,x到目前为止超过了2的值.蟒蛇

van*_*ren 0 python matplotlib

clist=[(-1.2720626442476508, 0.023952387163360456),
      (1.509233613482305, -1.196551723413994),
      (-0.37776845297034178, -1.9620288805522699),
      (-0.95028695770255522, -1.5670871848691932),
      (-0.19286972570683192, -1.2638500626369975),
      (1.19847548993563, 0.32781113190011446),
      (-0.93998357957640977, 0.74954973932266267),
      (-0.65151553614971647, -0.65350263688351395),
      (-0.65151553614971647, -0.65350263688351395)]

fig = plt.figure()
ax = plt.axes(xlim=(-2, 200), ylim=(-2, 2))
plt.plot(clist,'ro')
plt.show()
Run Code Online (Sandbox Code Playgroud)

如您所见,x坐标超过值2.y坐标是正确的.

如您所见,x坐标超过值2

Bre*_*ick 7

plt.plot(array)将在x坐标序列上绘制假定y坐标的数组.您需要明确传递plt.plot(xdata,ydata)以正确绘图.

在这种情况下plot(array),将输入表示:x = 0处的(y值,y值),x = 1处的(y值,y值)等.