【发布时间】:2012-07-25 13:43:05
【问题描述】:
我正在寻找一种方法来添加额外的轴对,包括倾斜和原点移位。应将它们添加到已用于显示图像的轴上。
结果应该看起来接近
y x+y
|\ /
9 | + -2 + 18
| \ /
| \ /
8 | x
| / \
| / \
7 | + 14 \x-y
|/ + 2
+--------------------- x
7 8 9
(很遗憾,我不被允许上传我创建的实际图像)
倾斜轴的中心应该定位在某个坐标 (x0,y0),在我的例子中是 (8,8),我希望能够像普通轴一样对待新轴,即对它们使用 set_xlabel、grid 等函数。
我尝试使用 Affine2D 变换、浮动轴和脊椎来获得结果,但无法正确处理这个问题。非常欢迎任何帮助。
图片中不重要的部分是用
完成的import numpy as np
import matplotlib.pyplot as plt
X = Y = np.linspace(7, 9, 100)
XX, YY = np.meshgrid(X,Y)
Z = np.exp(-(XX-XX.mean())**2/1 - (YY-YY.mean())**2/5)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.imshow(Z, origin='lower', extent=[X.min(), X.max(), Y.min(), Y.max()])
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.grid(True, color='white')
提前致谢。
【问题讨论】:
标签: python matplotlib axes