'Contour Plotting from the chamber measurement

What I got:
enter image description here

Expected result:
enter image description here

In the chamber measurement, Theta varies from -180:180 and phi varies from 0:180. I have to plot theta from 0:180 and phi from 0:360. How can I plot that in python without altering the dataset file but just in code?

import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm
from mpl_toolkits import mplot3d
import pandas as pd
from matplotlib import rcParams

df= pd.read_csv('Data.csv')
df.head()

Z=df.pivot(index="Phi", columns="Theta", values="E_total").T.values
X_unique = np.sort(df.Theta.unique())
Y_unique = np.sort(df.Phi.unique())

X, Y = np.meshgrid(X_unique, Y_unique)
fig = plt.figure()
ax = fig.add_subplot(111)
cpf = ax.contourf(X,Y,Z,20, cmap=cm.jet)
plt.colorbar(cpf)
ax.set_xlabel('Phi')
ax.set_ylabel('Theta')

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source