方副區(相等的高度和寬度)當我運行此代碼創建在matplotlib
from pylab import *
figure()
ax1 = subplot(121)
plot([1, 2, 3], [1, 2, 3])
subplot(122, sharex=ax1, sharey=ax1)
plot([1, 2, 3], [1, 2, 3])
draw()
show()
我得到兩個副區它們在X維度「壓扁」。對於兩個子圖,我如何得到這些子圖使得Y軸的高度等於X軸的寬度?
我在Ubuntu 10.04上使用matplotlib v.0.99.1.2。
更新2010-07-08:讓我們看看一些不起作用的東西。
經過Google整天搜索後,我認爲它可能與自動縮放有關。所以我試着擺弄它。
from pylab import *
figure()
ax1 = subplot(121, autoscale_on=False)
plot([1, 2, 3], [1, 2, 3])
subplot(122, sharex=ax1, sharey=ax1)
plot([1, 2, 3], [1, 2, 3])
draw()
show()
matplotlib堅持自動縮放。
from pylab import *
figure()
ax1 = subplot(121, autoscale_on=False)
plot([1, 2, 3], [1, 2, 3])
subplot(122, sharex=ax1, sharey=ax1, autoscale_on=False)
plot([1, 2, 3], [1, 2, 3])
draw()
show()
在這一個,數據完全消失。 WTF,matplotlib?只是WTF?
好吧,也許如果我們修復寬高比?
from pylab import *
figure()
ax1 = subplot(121, autoscale_on=False)
plot([1, 2, 3], [1, 2, 3])
axes().set_aspect('equal')
subplot(122, sharex=ax1, sharey=ax1)
plot([1, 2, 3], [1, 2, 3])
draw()
show()
這一個導致第一個子圖完全消失。那真好笑!誰想出了那個?
非常認真,現在......這真的應該是一件很難完成的事情嗎?
我使用axis('equal')更多的MATLAB像synthax。當MATLAB中的方面需要像「軸平方」時,我使用figure(1,figsize =(6,6))。 – otterb 2013-02-07 00:28:29
不幸的是,共享軸消失了,必須手動刪除標籤。這是不幸的:(。什麼,作品類型的工作是使用'subplot_kw = {'可調':'box-forced','aspect':'equal'}'作爲'subplots'的選項。軸標籤仍然顯示爲「共享」軸... – rubenvb 2015-11-05 10:33:54
OK ...你在哪裏找到'可調='box-forced'' API描述?我在這裏變得有點瘋狂... – Atcold 2017-02-08 15:05:24