I am wondering if it is possible to rotate each matplotlib contourf contour in my plot to a different angle. For example, the first plot I have is:
and I want to rotate some of the contours based on an angle. I have attached a new sketch I made of how I would like the contours to be rotated below:
where the added lines would represent the new contours. Say the 0.6-0.8 contour would be rotated either 55 or -55 degrees from the vertical, the 0.4-0.6 contour would be rotated 45 or -45 degrees from the vertical and the 0.2-0.4 contour would be rotated 50 or -50 degrees from the vertical.
The code I used to generate the first plot is given below.
import matplotlib.pyplot as plt
import numpy as np
def gaussian(x, mu, sig):
return np.exp(-np.power(x - mu, 2.) / (2 * np.power(sig, 2.)))
x_values = np.linspace(-5, 5, 120)
y_values = np.linspace(-5, 5, 120)
[xx,yy] = np.meshgrid(x_values,y_values)
xx = np.concatenate(xx)
yy = np.concatenate(yy)
y = gaussian(xx, 0, 1)
plt.figure()
plt.contourf(x_values,y_values,y.reshape(len(x_values),len(y_values)),levels=np.round(np.linspace(0,1,6),decimals=2))
plt.colorbar()