Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

pandas - Contour plotting in python

I am trying to plot the contour plot for the following data:-

enter image description here

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:- enter image description here

Note: Also suggest the changes in the code to be made.

question from:https://stackoverflow.com/questions/65937978/contour-plotting-in-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...