Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
331 views
in Technique[技术] by (71.8m points)

python - matplotlib.plot in Pyqt5


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You're almost there, you only need to modify your plot() function and use plot.set_xlim() like so:

...
...
    def plot(self):
        data = [random.random() for i in range(25)]
        plot = self.figure.add_subplot(111)
        plot.plot(data, 'r-')
        plot.set_xlim(left=-10) #<-- added here
        plot.set_title('PyQt Matplotlib Example')
        self.draw()

And it generates this plot:

enter image description here

As you can see, the x-axis has been extended to include negative number starting from -10.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...