Add generic heatplot method
@jamesramsden-bh is already working on this.
Since Mar 28, 2023.
Assessment
This issue has not been assessed yet.
Description
Implement the ability to generate plots like this below into the Python Toolkit, in a manner that can be inherited from and extended by other Python_TK-interiting toolkits.

Features to include:
- Ability to pass lists of X, Y, Z values
- Ability to enable contours and contour density
- Colormap
- Title
- Axis labels
- Enable or disable legend, and set title
- Apply formats to contour and legend values
The code below was used to generate the plot above:
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import griddata
import matplotlib.ticker as ticker
def myfmt(x, pos):
return '{0:.1f}'.format(x)
def pcfmt(x, pos):
return '{0:.0f}%'.format(x)
# Convert from pandas dataframes to numpy arrays
X0, Y0, Z0, = np.array([]), np.array([]), np.array([])
for i in range(len(X_dat)):
X0 = np.append(X0, X[i])
Y0 = np.append(Y0, Y[i])
Z0 = np.append(Z0, Z[i])
# create x-y points to be used in heatmap
xi = np.linspace(X0.min(), X0.max(), 1000)
yi = np.linspace(Y0.min(), Y0.max(), 1000)
# Interpolate for plotting
zi = griddata((X0, Y0), Z0, (xi[None,:], yi[:,None]), method='cubic')
# Create the contour plot
CS = plt.contourf(xi, yi, zi, 150, cmap="Oranges_r",
vmax=zi.max(), vmin=zi.min())
intervals = int(zi.max() - zi.min())
CS2 = plt.contour(xi, yi, zi, intervals, colors='k')
plt.clabel(CS2, inline=1, fontsize=10, colors='k', fmt=ticker.FuncFormatter(pcfmt))
plt.colorbar(CS, label="% hours comfortable", format=ticker.FuncFormatter(myfmt))
plt.xlabel("Evaporative cooling ratio")
plt.ylabel("Wind porosity ratio")
plt.title("% annual hours with UTCI between 9°C and 32°C")
plt.show()
cc @tg359
- Dominant language
- Python
- Stars
- 5
- Forks
- 1
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from BHoM/Python_Toolkit
-
type:feature
BHoM/Python_Toolkit#250 · 1 assignee ·
-
Searchable list box Opentype:feature
BHoM/Python_Toolkit#243 · 1 assignee ·
-
type:feature
Difficulty 4/5 3-5 days Newbie friendliness 35/100
BHoM/Python_Toolkit#234 ·
-
type:feature
BHoM/Python_Toolkit#228 · 1 assignee ·
-
Colormap builder Opentype:feature
BHoM/Python_Toolkit#217 · 1 assignee ·
All issues in BHoM/Python_Toolkit
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
learningequality/ricecooker#747 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
run-llama/llama_index#23199 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
KhronosGroup/glTF-Blender-IO#2769 ·