I am trying to produce a density plot in polar coordinates if I have a list of angles amplitudes in degrees in a dihedrals.txt file: for example: 359.262 13.174 352.603 334.395 351.922 8.914 354.485 340.591 15.376 351.65 21.108 338.342 9.592 359.583 13.285 354.237 22.613 6.483 0.542 336.274 12.243 12.563 346.091
I have read some of the answers here but so far I have not found anything that works for what I want. This is an example of the code I have tried to use:
# Import environmental variables from bash script
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from scipy.stats import gaussian_kde
from matplotlib.colors import Normalize
from scipy.interpolate import interpn
import math
second_count=8
Tt = 1
angles = np.loadtxt('dihedrals.txt')
sin_angles = np.sin(angles)
cos_angles = np.cos(angles)
xy = np.vstack([sin_angles, cos_angles])
z = gaussian_kde(xy)(xy)
# Compute areas and colors
r = 2 * angles
theta = 2 * np.pi * angles
area = 10 * r**2
colors = theta
fig = plt.figure()
ax1 = fig.add_subplot(projection='polar')
ax1.scatter(sin_angles, cos_angles, c=z, alpha = 0.75)
plt.show()
