Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Add generic heatplot method

未关闭
#101 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@jamesramsden-bh 已经在做这个了。

开始于 2023年3月28日。

评估

这个 Issue 还没有评估数据。

描述

type:feature

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.

download

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

主要语言
Python
星标
5
派生
1
平均合并
1 天 10 小时
30 天内合并 PR
4

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

BHoM/Python_Toolkit 的其他 Issue

查看 BHoM/Python_Toolkit 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。