I have a script in python for temperature visualisation. Input data are something like this:
imported excel table
I have this code, it works fine:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# import data from excel file
df = pd.read_excel('temperature_data.xlsx', index_col=0)
# Assign columns to variables
places = df.columns
depth = df.index
temperature = np.ma.masked_invalid(df.to_numpy())
# Creating the graph
fig, ax = plt.subplots()
min_temp = temperature.min()
max_temp = temperature.max()
cs = plt.contourf(places, depth, temperature, cmap='coolwarm', vmin=min_temp, vmax=max_temp)
cs2 = plt.contour(places, depth, temperature, levels=range(round(min_temp), round(max_temp)+1, 1), colors='black')
plt.clabel(cs2, inline=1, fontsize=10, fmt='%d')
plt.title('Teplota vody [°C]')
#plt.xlabel('Places')
plt.ylabel('hloubka [m]')
plt.colorbar(cs, cmap='coolwarm')
plt.gca().invert_yaxis()
plt.show()
But I want the visualisation with the smooth contours and the bottom line. Something like this:
desired output
Can you help me, please? Thank you very much, Dušan.
I’ve tried to write an included script.
New contributor
Dušan K. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1