2017-06-21 34 views
0

我只想用一個數字,多個,不同的和可修改的地塊,而不使用子地塊形式。在python中疊加獨立地塊

有沒有一種方法來疊加兩個不同的地塊,就像文本框一樣,即圖上的任何位置?

這裏是 「瘸子製造」 的例子:

random graphs to show what I expect

謝謝!

回答

1

您可以使用figure.add_axes將軸放置在任意位置。

fig = plt.figure() 
fig.add_axes([0.1,0.2,0.3,0.4]) 

在圖的座標上放置x = 0.1,y = 0.2,寬度= 0.3,高度= 0.4的座標軸。

from mpl_toolkits.mplot3d import Axes3D 
import matplotlib.pyplot as plt 
import numpy as np 

fig = plt.figure() 

ax = fig.add_axes([0.4,0.1,0.5,0.6], projection='3d') 
X, Y = np.meshgrid(np.arange(-5, 5, 0.25), np.arange(-5, 5, 0.25)) 
Z = np.sin(np.sqrt(X**2 + Y**2)) 
surf = ax.plot_surface(X, Y, Z, cmap="plasma") 

ax = fig.add_axes([0.3,0.4,0.3,.4]) 
plt.plot([1,2,3]) 

plt.show() 

enter image description here

+0

哦... :(。我想我已經看了足夠的庫。所以,謝謝! – QuentinL