How to make a contour plot in python(matplotli) - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to make a contour plot in python(matplotli) (/thread-22821.html) |
How to make a contour plot in python(matplotli) - Ardi - Nov-28-2019 Can some one help me. I want to make a contour plot let's say an example of my data below. I have height data and temperatur data in csv file for 4 day : And this is my script tried :import pandas as pd import matplotlib.pyplot as plt import numpy as np import matplotlib.colors as colors import csv import glob import os path = "C:/Users/SYIFAAZRA/Documents/belajar_wradlib/Skew-T/New/" os.chdir(path) filenames = glob.glob("*.csv") dfs = [] for f in filenames: col_names = ['height', 'temp'] df = pd.read_csv(f, delimiter=',',skiprows=7, usecols=[11, 21], names=col_names, na_values=['----']) df = df.dropna() max = df.height.idxmax() min = df.height.idxmin() df = df.loc[min:max, :] dfs.append(df) df2 = pd.concat(dfs, ignore_index=False, axis=1) fig = plt.figure() ax = fig.add_subplot(111) x = np.linspace(0,100, 50) y = df['height'] X,Y = np.meshgrid(x, y) Z = df['temp'] plt.show()I want to make a contour plot which x= number of date, y=height data, z=temp data. Can someone suggest to me how to resolve my script above. |