Question: Python Matplotlib Contour Plot with 3 list I am obtaining three list from a datframe that I'd like to use in the creation of a

Python Matplotlib Contour Plot with 3 list

I am obtaining three list from a datframe that I'd like to use in the creation of a contour plot. I have the x values, y values, and slope(Z).

x = [array([ 0. , 0.02381252]), array([ 0. , 0.01637109]), array([ 0. , 0.00818555]), array([ 0. , 0.00327422]), array([ 0. , 0.02232422]), array([ 0. , 0.01726406]), array([ 0. , 0.01012031]), array([ 0. , 0.00342305]), array([ 0. , 0.02247305]), array([ 0. , 0.01771055]), array([ 0. , 0.00967383]), array([ 0. , 0.00520898])] y = [array([ 34.41714142, 10943.01686138]), array([ -156.31101096, 8339.95110426]), array([ -153.67381043, 4080.08545154]), array([ -120.27230344, 1066.3326922 ]), array([ 86.67133362, 10747.91103271]), array([ -39.93200841, 8320.97197016]), array([ -82.51007639, 4769.06846761]), array([ -226.8960146 , 1141.95196454]), array([ 26.70330339, 11045.17728382]), array([ -60.69589768, 8321.19725595]), array([ -49.12681894, 4642.3457806 ]), array([ -148.70638517, 1916.35841797])] slope = [458103.5522928648, 518979.5059451843, 517223.7532849595, 362408.60013225337, 477563.83028931776, 484295.27869248175, 479390.18248112994, 399891.69432647835, 490297.2969366774, 473271.300539092, 484965.4628827713, 396442.8786196624] 

I have tried a variety of ways to create a contour map with these values, using the following code, the contour map comes out odd, looking like straight bars. How can I properly plot these values within a contour plot? Thank you!

 import pandas as pd import matplotlib.pyplot as plt import matplotlib from pandas import * x = workingDf['xvals'].tolist() y = workingDf['yvals'].tolist() z = workingDf['Kx'].tolist() X, Y = np.meshgrid(x, y) Z = np.sqrt(X**2 + Y**2) plt.contour(X,Y,Z) plt.show() 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!