I am trying to plot the contour plot for the following data:-
My query I want to do a contour plot in python and given below is my code:
enter code here
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import numpy as np
import matplotlib.pyplot as plt
load_var=pd.read_excel(r'pathfilename.xlsx')
x=load_var['Time stamp']
y=load_var['Note']
z=['frequency of occurence']
reshaped_to_2d = np.reshape(z, (-1, 2))
plt.contourf(x,y,z,cmap="jet")
plt.colorbar()
plt.show()
Error1: "TypeError: Input z must be 2D, not 1D"
after this error i added reshaped_to_2d = np.reshape(z, (-1, 2)) this in the above code.
After which I got the error of "Length of passed values is 14832, index implies 29664"
Note: I want to generate the contour plot wherein the "Notes " should be on y-Axis and "timestamp" on X-axis and the NUmber of frequency plotted as a spectrum along with the colour bar on the right-hand side of the contour plot.
I have included a demo plot below:-
Note: Also suggest the changes in the code to be made.
question from:
https://stackoverflow.com/questions/65937978/contour-plotting-in-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…