如何在图形的X轴上显示更多的数字?

2024-06-25 22:44:31 发布

您现在位置:Python中文网/ 问答频道 /正文

(免责声明:我学习python/编程不到一周)

这是专门针对Python的。我使用的是scipy库:Numpy和MatPlotLib。在

如您所见,X轴每50个单位显示一次。我想它显示每10个单位的数字。在

我怎么才能改变这个?

我的代码输出: Python Graph

生成图形的代码:

x1 = []
y1 = []
x2 = []
y2 = []
x3 = []
y3 = []

def ShowMyGraph():
    plot1, = pl.plot(x1,y1,'r.')
    plot2, = pl.plot(x2,y2,'b_')
    plot3, = pl.plot(x3,y3,'-')

    pl.title('Random Encounter Pattern')
    pl.xlabel('StepID')
    pl.ylabel('Danger Value')

    pl.xlim(0.0,200.0)
    pl.ylim(0.0,8000)

    pl.legend([plot1,plot2], ('Steps', 'Battles'), 'best', numpoints=1)
    pl.show()

def PlotSteps():
    x1.append(stepid)
    y1.append(danger)
    x2.append(stepid)
    y2.append(dlimit)
    x3.append(stepid)
    y3.append(dlimit)

def dosomething():
     PlotSteps()

ShowMyGraph()

Tags: 代码plotdef单位plx1x2append