matplotlib basemap - pyqt5: how to zoom in a figure on both x axes and y axes together? -
i want plot figure pyqt5 below codes, , want see data in 1 figure , zoom in see detals; hope when Izoom in part of figure, x axes , y axes fit detail auto together;
import sys pyqt5 import qtwidgets matplotlib.backends.backend_qt5agg import figurecanvasqtagg figurecanvas matplotlib.backends.backend_qt5 import navigationtoolbar2qt navigationtoolbar import matplotlib.pyplot plt import matplotlib.finance mpf class window(qtwidgets.qdialog): def __init__(self,data,parent=none): super().__init__(parent) self.candledata=data[0] self.plots=len(data) if self.plots>1: self.linedata=data[1] self.figure = plt.figure(figsize=(30,18)) self.axes = self.figure.add_subplot(111) self.axes.hold(true) self.canvas = figurecanvas(self.figure) self.toolbar = navigationtoolbar(self.canvas, self) self.toolbar.hide() self.button2 = qtwidgets.qpushbutton('zoom') self.button2.clicked.connect(self.zoom) self.button3 = qtwidgets.qpushbutton('pan') self.button3.clicked.connect(self.pan) self.button4 = qtwidgets.qpushbutton('home') self.button4.clicked.connect(self.home) layout = qtwidgets.qvboxlayout() layout.addwidget(self.toolbar) layout.addwidget(self.canvas) btnlayout = qtwidgets.qhboxlayout() btnlayout.addwidget(self.button2) btnlayout.addwidget(self.button3) btnlayout.addwidget(self.button4) qw = qtwidgets.qwidget(self) qw.setlayout(btnlayout) layout.addwidget(qw) self.setlayout(layout) def home(self): self.toolbar.home() def zoom(self): self.toolbar.zoom() def pan(self): self.toolbar.pan() def plot(self): [obj.insert(0,i) i,obj in enumerate(self.candledata)] mpf.candlestick_ohlc(self.axes,self.candledata,width=0.8,colorup='r',colordown='g') self.axes.grid() print(self.plots) if self.plots>1: in range(len(self.linedata)): self.axes.plot(self.linedata[i][0],self.linedata[i][1],color=self.linedata[i][2]) self.canvas.draw()
now plot figure , zoom in small part blow:
screenshot:
but should use "pan" see of it; shall see of auto when zoom in?
Comments
Post a Comment