I am trying to rotate an embedded plot as a whole (i.e. the x axis of the plot should be in 45 degrees with x axis of embed plot). An example code providing a rotated embedded plot according to How to rotate a simple matplotlib Axes can be found below. The rotation does not seem to rotate the data but just the axis. In addition, I can't yet figure out how to move the embed plot within this figure
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.colors as colors
import matplotlib as mpl
from matplotlib.transforms import Affine2D
import mpl_toolkits.axisartist.floating_axes as floating_axes
def add_subplot_axes(ax,rect,axisbg='w'):
fig = plt.gcf()
box = ax.get_position()
width = box.width
height = box.height
inax_position = ax.transAxes.transform(rect[0:2])
transFigure = fig.transFigure.inverted()
infig_position = transFigure.transform(inax_position)
x = infig_position[0]
y = infig_position[1]
width *= rect[2]
height *= rect[3]
subax = fig.add_axes([x,y,width,height])
x_labelsize = subax.get_xticklabels()[0].get_size()
y_labelsize = subax.get_yticklabels()[0].get_size()
x_labelsize *= rect[2]**0.5
y_labelsize *= rect[3]**0.5
subax.xaxis.set_tick_params(labelsize=x_labelsize)
subax.yaxis.set_tick_params(labelsize=y_labelsize)
return subax
St=np.zeros((150,150))
k=np.random.sample(150)
np.fill_diagonal(np.fliplr(St), k)
fig=plt.figure(figsize=(10,10))
ax=fig.add_subplot(111)
ax.imshow(St,cmap='Greys')
plot_extents = 0, 10, 0, 10
transform = Affine2D().rotate_deg(45)
helper = floating_axes.GridHelperCurveLinear(transform, plot_extents)
ax1 = floating_axes.FloatingSubplot(fig, 111, grid_helper=helper)
ax1.plot(np.arange(0,10),(0,1,2,3,4,5,7,9,10,10))
fig.add_subplot(ax1)
plt.show()