From: Umut Y. <yi...@st...> - 2012-05-24 19:15:17
|
Dear All, I used to use griddata in order to make my contourmaps. However, after I updated my Python from 2.6 to 2.7 griddata is not working anymore. I tried some workarounds but no success. The countourmap that I produced before is here. http://dl.dropbox.com/u/17983476/matplotlib/contour_dT_workingbefore.png After the Python 2.7 update, it turns to the following. http://dl.dropbox.com/u/17983476/matplotlib/contour_dT_broken.png Here is the datafile. http://dl.dropbox.com/u/17983476/matplotlib/contour_dT.dat And the associated python script (which is also below). http://dl.dropbox.com/u/17983476/matplotlib/contour_dT.py The code that I was using before is here. I had to comment out #import griddata line because this is the only way that it continues. Is this a bug in griddata, or if there are new workarounds, I would be glad to know a new method to produce my contourplots again. Thanks a lot ---------------------------- #! /usr/bin python import os import sys import math from math import * from numpy import * #import griddata from pylab import * from matplotlib.ticker import FormatStrFormatter params = {'axes.labelsize': 20, 'text.fontsize': 15, 'legend.fontsize': 14, 'xtick.labelsize': 20, 'ytick.labelsize': 20, 'text.usetex': True } rcParams.update(params) par1 = [] par2 = [] chis = [] rfile = file('contour_dT.dat','r') line = rfile.readline() data = line.split() while len(data) >1: par1.append(float(data[0])) par2.append(float(data[1])) chis.append(float(data[2])) line = rfile.readline() data = line.split() par1 = array(par1) par2 = array(par2) chis = array(chis) xi = linspace(3.2,7.8,50) yi = linspace(15,300,50) zi = griddata(par2,par1,chis,xi,yi) levels = [0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.5,2,3,4,6,10,12,15,20,25,30,40,50] CS = contourf(xi,yi,zi,levels,cmap=cm.jet) CS2 = contour(CS, levels=CS.levels[::2], colors = 'r', hold='on') cbar = colorbar(CS) cbar.add_lines(CS2) savefig("contour_dT.png") show() |