Python Forum

Full Version: Creating a colored Contour Plot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is a homework problem
1. WCT is a function of two variables (T and wind speed). Perform a bivariate sensitivityanalysis.a. Plot filled contours of WCT as a function of T (from -40 deg. F to +40 deg. F) and wind speed (from 0 to 60 mph). Choose an appropriate colormap. 

I have this so far but its not working. 

import matplotlib.pyplot as plt
import numpy as np

xlist=np.linspace(-40,40,1)
ylist=np.linspace(0,60,61)

(x,y) = np.meshgrid(xlist,ylist)

for value in (x,y):

        z=(35.74+(.6215*x)-(35.75*(y**.16))+(.3965*x*(y**.16)))

plt.figure()

cp=plt.contourf(x,y,z)
plt.xlabel('Degrees F')
plt.ylabel('Wind Speed (mph)')
plt.show()
When I run this I get a plot with the axis labeled but nothing in the middle

The formula for wind chill temperature (WCT) is found at https://en.wikipedia.org/wiki/Wind_chill...hill_index using the USA formula
Your xlist (temperature) contains only one value, perhaps there should be something like
xlist=np.linspace(-40,40,81) 
Wow..
Morever, there is no need for a for loop in your code. As numpy operations are vectorized, simple statement z = (.... ) is enough.