Python Forum
Creating a colored Contour Plot
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a colored Contour Plot
#1
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
Reply
#2
Your xlist (temperature) contains only one value, perhaps there should be something like
xlist=np.linspace(-40,40,81) 
Reply
#3
Wow..
Reply
#4
Morever, there is no need for a for loop in your code. As numpy operations are vectorized, simple statement z = (.... ) is enough.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Colored text output in python 3 groovydingo 3 18,337 Apr-06-2018, 05:42 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020