Bottom Page

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.
Gribouillis wrote Nov-28-2019, 07:12 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

I fixed for you this time. Please use code tags on future posts.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How can I make a plot representing connection relationship with python matplotlib? Berlintofind 1 176 May-08-2020, 09:27 PM
Last Post: jefsummers
  Matplotlib contour no data coordinates b4rtt 1 632 Jun-18-2019, 09:36 AM
Last Post: b4rtt
  How to plot vertically stacked plot with same x-axis and SriMekala 0 405 Jun-12-2019, 03:31 PM
Last Post: SriMekala
  Contour Sort Explain Killing_Machine 0 605 Aug-18-2018, 10:41 AM
Last Post: Killing_Machine

Forum Jump:


Users browsing this thread: 1 Guest(s)