Python Matplotlib线型不一致的破折号

Python Matplotlib线型不一致的破折号,python,matplotlib,Python,Matplotlib,我正在用MPL1.4.0绘制一个简单的散点图。我希望控制正在打印的图形上的虚线数量,因为当前即使我设置了线型,虚线之间的距离也太近,因此看起来不像一条正确的虚线 #load cdeax,cdeay,gsix,gsiy,reich all are arrays of shape (380,) figfit = plt.figure(); axfit = figfit.gca() axfit.plot(cdeax,np.log(cdeay),'ko', alpha=.5); axfit.plot

我正在用MPL1.4.0绘制一个简单的散点图。我希望控制正在打印的图形上的虚线数量,因为当前即使我设置了线型,虚线之间的距离也太近,因此看起来不像一条正确的虚线

#load cdeax,cdeay,gsix,gsiy,reich all are arrays of shape (380,)
figfit = plt.figure(); axfit = figfit.gca() 

axfit.plot(cdeax,np.log(cdeay),'ko', alpha=.5); axfit.plot(gsix,np.log(gsiy), 'kx')
axfit.plot(cdeax,cdeafit,'k-'); axfit.plot(gsix,gsifit,'k:')
longevityregplot[1].plot(gsix,np.log(reich_l),'k-.')


然而,以上是我得到的。线不是均匀的虚线,而是在端点以不同的程度虚线,但无论我对虚线使用什么值,虚线永远都不是均匀的

恐怕我真的不知道这里有什么问题。。。有什么想法吗

我已在此处粘贴了我正在使用的阵列: 您应该能够将它们复制/粘贴到IDE中,以运行上述代码

干杯

编辑:

仅绘制单线图:

axfit.plot(cdeax,cdeafit,'k-',dashes = [10,10]); 

EDIT2:pastebin链接已更改为包含所有数据

编辑3:沿x轴的点密度直方图:


我认为@cphlewis所说的是正确的,你可能有一些x轴回溯。如果我把所有的东西都分类,我觉得还可以(我自己试穿了,因为我仍然看不到pastebin上的合身)


在我看来,你在两条虚线的上方绘制,它们相互抵消了对方的虚线。如果你只是在一个清除的轴上进行
axfit.plot(cdeax,cdeafit,'k-',破折号=[10,10])
,线条如何?我用一个新的图像编辑了我的文章,同样的情况也会发生。检查数据是否在5-10度范围内重复或无序数据?它们不必重复,但如果-,这似乎不太可能,除了它看起来是对的——如果绘图回溯,你可以得到这个效果。像x值一样,运行[1,2,5,3,4],而不是[1,2,3,4,5]。什么das
axfit.plot(排序(cdeax),排序(cdeafit),'k-',破折号=[10,10])给予?(只要拟合曲线是单调递增的,就应该允许)
axfit.plot(cdeax,cdeafit,'k-',dashes = [10,10]); 
# import your data here
import math
figfit = plt.figure(); axfit = figfit.gca() 

cdea = zip(cdeax,cdeay)
cdea = np.array(sorted(cdea, key = lambda x: x[0]))

gsi = zip(gsix,gsiy)
gsi = np.array(sorted(gsi, key = lambda x: x[0]))

cdeafit2 = np.polyfit(cdea[:,0],cdea[:,1],1)
gsifit2 = np.polyfit([x[0] for x in gsi],[math.log(x[1]) for x in gsi],1)

cdeafit = [x*cdeafit2[0] + cdeafit2[1] for x in cdea[:,0]]

gsifit = [math.exp(y) for y in [x*gsifit2[0] + gsifit2[1] for x in gsi[:,0]]]

axfit.plot(cdea[:,0],cdea[:,1],'ko', alpha=.5); axfit.plot(gsi[:,0],gsi[:,1], 'kx')
axfit.plot(cdea[:,0],cdeafit,'k-',dashes = [10,10]); axfit.plot(gsi[:,0],gsifit,'k:',dashes=[10,10])
#longevityregplot[1].plot(gsix,np.log(reich_l),'k-.') # not sure what this is
axfit.set_yscale('log')
plt.show()