0
我正在努力解決如何放大整個圖形,而不僅僅是圖中的子圖。以下代碼是稍作修改的matplotlib示例,並顯示可以手動調整子圖軸的限制。同樣,盒子縮放僅允許放大子圖(或相關的子圖)。如何放大整個數字?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()
究竟你的意思「放大整個數字'?只要把窗戶變大一點? – tacaswell
窗口大小爲400x400,圖形大小爲300x300,子圖大小爲100x200。將窗口保持在400x400,將圖形大小更改爲500x500(即,如果不適合窗口,則切斷)並相應地縮放子圖大小。現在我想我會看到如何做到這一點 - 根據需要設置圖形大小;-) –
通過設計,藝術家定位的最頂層是在「圖形分數」中完成的,大多數默認GUI嵌入將圖形大小匹配以匹配窗口大小。如果你已經整理出來了,請回答你自己的問題。 – tacaswell