What kind of transformation when the aspect is changed for a rotated shape? I have a geometric shape (assuming that is a rectangle). I want to rotate it about it geometric center by an angle of 45° and plot the result using matplotlib with an equal aspect ratio, I get something like this:

However for some reason, I want to plot the result in a figure with a non-equal aspect, I am getting this result:

As you can see, the rotated shape is deformed (skewed). But the original shape seems to be scaled only in the y direction.
I am trying to understand what kind of transformation is occuring to the orange shape from a linear algebra perspective: Is it a shear? a combination of scaling and shear (Affine transformation)? if not what kind of transformation is that?
My goal is to identify the type of transformation, then finding it's inverse to get the following result:

I appreciate any help.
Let's talk about linear geometric transformations in homogeneous coordinates.  In your question there are mainly two kind of geometric transformations involved: planar rotation and planar scaling, the computation-friendly analytical re-definitions of which are found hereUnified frameworks of elementary geometric transformations.

The 2D homogenous rotation matrix that rotates 2D objects clockwise by $\theta$ radians is as below:

$$R=\left[
\begin{array}{ccc}
 \cos \theta &amp; \sin \theta&amp; 0 \\
 -\sin\theta &amp; \cos\theta &amp; 0 \\
 0 &amp; 0 &amp; 1 \\
\end{array}
\right]$$

A 2D scaling due to unequal aspect ratio $\rho$ in this case is a stereohomology with $x$ axis $(0,1,0)^T$ as the stereohomology interface (a line of invariant points), and the normal direction $(0,1,0)^T$ as its stereohomology center per definition 3.9 in page 12 and line No. 5 in Table 1, page 9 of the article Unified frameworks of elementary geometric transformations. Then its scaling matrix can be obtained as below:

$$S=\color{gray}{\left[
\begin{array}{ccc}
 1 &amp; 0 &amp; 0 \\
 0 &amp; 1 &amp; 0 \\
 0 &amp; 0 &amp; 1 \\
\end{array}
\right]+\left(\rho-1\right)\dfrac{\left[
\begin{array}{c}
 0 \\
 1 \\
 0 \\
\end{array}
\right]\cdot \left[
\begin{array}{ccc}
 0 &amp; 1 &amp; 0 \\
\end{array}
\right]}{\left[
\begin{array}{ccc}
 0 &amp; 1 &amp; 0 \\
\end{array}
\right]\cdot \left[
\begin{array}{c}
 0 \\
 1 \\
 0 \\
\end{array}
\right]}=}\left[
\begin{array}{ccc}
 1 &amp; 0 &amp; 0 \\
 0 &amp; \rho  &amp; 0 \\
 0 &amp; 0 &amp; 1 \\
\end{array}
\right]$$

When aspect ratio normally is $\rho=1$, suppose under this circumstance the original object has the homogeneous coordinates of $n$ points in $3\times n$ matrix $X$, and the transformed object in $3\times n$ matrix $Y$, then the geometric transformation between them is the rotation you have mentioned:

$$Y=R\cdot X$$

When the aspect ratio abnormally is $\rho\ne 1$, both $X$ and the $Y$ after rotation are as a matter of fact scaled along the $y$ axis:

$$X'=S\cdot X$$
$$Y'=S\cdot Y$$

Now you want to find the geometric transformation $T$  which satisfies $Y'=T\cdot X'$. Since:

$$Y'=S\cdot Y=S\cdot R\cdot X =S\cdot R\cdot S^{-1}\cdot X'$$

then

$$T=S\cdot R\cdot S^{-1}$$ 
$$=\color{gray}{\left[
\begin{array}{ccc}
 1 &amp; 0 &amp; 0 \\
 0 &amp; \rho  &amp; 0 \\
 0 &amp; 0 &amp; 1 \\
\end{array}
\right]
\cdot
\left[
\begin{array}{ccc}
 \cos \theta &amp; \sin \theta&amp; 0 \\
 -\sin\theta &amp; \cos\theta &amp; 0 \\
 0 &amp; 0 &amp; 1 \\
\end{array}
\right]\cdot
\left[
\begin{array}{ccc}
 1 &amp; 0 &amp; 0 \\
 0 &amp; \dfrac{1}\rho  &amp; 0 \\
 0 &amp; 0 &amp; 1 \\
\end{array}
\right]=}\left[
\begin{array}{ccc}
 \cos \theta &amp; \dfrac{\sin \theta}{\rho } &amp; 0 \\
 -\rho  \sin\theta &amp; \cos \theta&amp; 0 \\
 0 &amp; 0 &amp; 1 \\
\end{array}
\right]$$

It is a rotation under the generalized meaning.