Python Forum
How to make a contour plot in python(matplotli)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a contour plot in python(matplotli)
#1
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 :
Output:
date 1 date 2 date 3 date 4 height temp height temp height temp height temp 9.3 28.0 8.7 27.6 10.0 26.0 9.5 26.8 9.7 27.3 9.3 26.8 12.8 25.5 10.8 25.9 10.0 26.8 10.8 25.9 13.1 25.3 11.4 25.0 10.6 26.5 12.7 24.4 14.8 24.7 12.9 24.2 12.8 26.0 13.5 23.8 15.2 24.3 13.6 23.4 13.3 25.7 17.8 22.7 16.8 23.7 14.0 22.6 16.8 25.4 18.9 22.4 17.9 23.3 14.7 22.0 17.2 24.6 20.0 21.0 18.6 23.0 15.9 21.3
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.
Reply


Messages In This Thread
How to make a contour plot in python(matplotli) - by Ardi - Nov-28-2019, 04:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Vertex(Contour) to mesh conversion JorgeRdz 1 722 Feb-06-2023, 02:00 AM
Last Post: Larz60+
  Error 'Contour' not Defined DaveG 3 2,353 Mar-13-2022, 03:29 AM
Last Post: deanhystad
  How to plot intraday data of several days in one plot mistermister 3 2,914 Dec-15-2020, 07:43 PM
Last Post: deanhystad
  How can I make a plot representing connection relationship with python matplotlib? Berlintofind 1 1,954 May-08-2020, 09:27 PM
Last Post: jefsummers
  Matplotlib contour no data coordinates b4rtt 1 2,651 Jun-18-2019, 09:36 AM
Last Post: b4rtt
  How to plot vertically stacked plot with same x-axis and SriMekala 0 1,929 Jun-12-2019, 03:31 PM
Last Post: SriMekala
  Contour Sort Explain Killing_Machine 0 1,919 Aug-18-2018, 10:41 AM
Last Post: Killing_Machine

Forum Jump:

User Panel Messages

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