python - 具有非正交轴的 imshow (即平行四边形)

标签 python matplotlib

我有沿两个非正交向量 a、b 采样的二维数据数组

a = |a|.( cos(alfa), sin(alfa) )

b = |b|.( cos(beta), sin(beta) )

(即不沿着正交笛卡尔方向 x, y)

我想绘制未扭曲的数据(即作为平行四边形而不是矩形)

matplotlib 中有没有函数可以做到这一点?

我需要它来绘制这样的数据(c,f,i)

enter image description here

最佳答案

像这样使用仿射变换怎么样 example ,

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms

def get_image():
    from scipy import misc
    Z = misc.imread('31271907.jpg')
    return Z

# Get image
fig, ax = plt.subplots(1,1)
Z = get_image()

# image skew
im = ax.imshow(Z, interpolation='none', origin='lower',
                 extent=[-2, 4, -3, 2], clip_on=True)
im._image_skew_coordinate = (3, -2)

plt.show()

它使用图像

enter image description here

并将其变成,

enter image description here

关于python - 具有非正交轴的 imshow (即平行四边形),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31271907/

相关文章:

python - Matplotlib/Imshow/透明层无处不在但某些点

python - 在 matplotlib 图形中绘制平滑曲线

python - 如何在 python matplotlib 中添加第三级刻度

python - Google Play商店会自动建议吗?

python - Matplotlib 多网格 zorder 不适用于错误栏

python - 使用 NumPy datetime64 向量化年/月/日操作

python - 分层数据 : efficiently build a list of every descendant for each node

python - PySide 商业应用中的 Matplotlib

Python - 带有元组的 Pandas 数据框

Python:模拟的调用计数无法通过多处理并行执行