我正在尝试如何缩放整个图形,而不仅仅是图形中的子图。下面的代码是对matplotlib稍作修改的示例,说明可以手动调整子批次轴限制。同样的,框缩放只允许放大子图(或链接的子图)。如何缩放整个图形?在
from matplotlib.pyplot import figure, show
import numpy
figsrc = figure()
axsrc = figsrc.add_subplot(121, xlim=(0,1), ylim=(0,1), autoscale_on=False)
axzoom = figsrc.add_subplot(122, xlim=(0.45,0.55), ylim=(0.4,.6),
autoscale_on=False)
axsrc.set_title('Click to zoom')
axzoom.set_title('zoom window')
x,y,s,c = numpy.random.rand(4,200)
s *= 200
axsrc.scatter(x,y,s,c)
axzoom.scatter(x,y,s,c)
def onpress(event):
if event.button!=1: return
x,y = event.xdata, event.ydata
axzoom.set_xlim(x-0.1, x+0.1)
axzoom.set_ylim(y-0.1, y+0.1)
figsrc.canvas.draw()
figsrc.canvas.mpl_connect('button_press_event', onpress)
show()
一种方法是使用画布.调整大小调整大小方法。在
请注意,“主页”按钮不会恢复原始视图。我没能追踪到工具栏.home()方法QtCore.Qt.Key_主页:后端中的“home”_qt5.py:
相关问题 更多 >
编程相关推荐