import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-10, 10, 1)
y = np.arange(-10, 10, 1)

xx, yy = np.meshgrid(x, y)
plt.scatter(xx, yy, s=30, c=xx+yy)
# [...] Add axis, x and y witht the same scale
<matplotlib.collections.PathCollection at 0x1227627f0>
T = np.array([
    [-1, 0],
    [0, -1]
])
xy =  np.vstack([xx.flatten(), yy.flatten()])
xy.shape
(2, 400)
trans = T @ xy
trans.shape
(2, 400)
xx_transformed = trans[0].reshape(xx.shape)
yy_transformed = trans[1].reshape(yy.shape)
f, axes = plt.subplots(1, 2, figsize=(6, 3))
axes[0].scatter(xx, yy, s=10, c=xx+yy)
axes[1].scatter(xx_transformed, yy_transformed, s=10, c=xx+yy)
# [...] Add axis, x and y witht the same scale
<matplotlib.collections.PathCollection at 0x1228cc4f0>
T = np.array([
    [1.3, -2.4],
    [0.1, 2]
])
trans = T @ xy

xx_transformed = trans[0].reshape(xx.shape)
yy_transformed = trans[1].reshape(yy.shape)

f, axes = plt.subplots(1, 2, figsize=(6, 3))
axes[0].scatter(xx, yy, s=10, c=xx+yy)
axes[1].scatter(xx_transformed, yy_transformed, s=10, c=xx+yy)
# [...] Add axis, x and y witht the same scale
<matplotlib.collections.PathCollection at 0x12297f6d0>
# T_inv @ T @ v = I @ v = v
T = np.array([
    [1.3, -2.4],
    [0.1, 2]
])
trans = T @ xy

T_inv = np.linalg.inv(T)

un_trans = T_inv @ T @ xy

f, axes = plt.subplots(1, 3, figsize=(9, 3))
axes[0].scatter(xx, yy, s=10, c=xx+yy)
axes[1].scatter(trans[0].reshape(xx.shape), trans[1].reshape(yy.shape), s=10, c=xx+yy)
axes[2].scatter(un_trans[0].reshape(xx.shape), un_trans[1].reshape(yy.shape), s=10, c=xx+yy)
<matplotlib.collections.PathCollection at 0x122a6f2e0>
# transformation by a singular matrix cannot be reset because the points 
# land on each other in the same space hence non retrievable
T = np.array([
    [3, 6],
    [2, 4],
])
trans = T @ xy

f, axes = plt.subplots(1, 2, figsize=(6, 3))
axes[0].scatter(xx, yy, s=10, c=xx+yy)
axes[1].scatter(trans[0].reshape(xx.shape), trans[1].reshape(yy.shape), s=10, c=xx+yy)
# [...] Add axis, x and y witht the same scale
<matplotlib.collections.PathCollection at 0x122b0d9a0>