1

I have 2D array of data sampled along two vectors non-orthogonal a, b

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

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

(i.e not along orthogonal cartesian direction x, y)

I would like to plot this data un-distorted (i.e. as parallelogram instead of rectangle)

is there any function to do that in matplotlib?

I need it for plotting data like this (c, f , i)

enter image description here

1
  • I'm not sure exactly how it should be done, but something like this may help. Commented Jul 7, 2015 at 15:30

1 Answer 1

1

What about using an affine transform as in this 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()

Which uses the image

enter image description here

and turns it into,

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Hi, it is very useful, I just don't understand what _image_skew_coordinate = (3, -2) exactly mean. I would expect something like 2x2 affine transform matrix, but this is just one vector which tilts both x and y axes
Hi @ProkopHapala, the _image_skew_coordinate has no documentation as it is for "internal use", so the use in the linked example seems a bit like a hack. From the Affine transform docs it looks possible the two numbers specify shear angles along the x- and y-axes, respectively, in radians (see matplotlib.org/devel/…).
I don't think it is angle in radians since the number is round (integer) ... I think it is simply the coordinate of one of the skewed corners ... the second corner is assumed to be symmetric

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.