Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add generic heatplot method

Đang mở
#101 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

@jamesramsden-bh đang làm issue này rồi.

Từ ngày 28/3/2023.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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

Ngôn ngữ chính
Python
Star
5
Fork
1
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
4

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của BHoM/Python_Toolkit

Tất cả issue của BHoM/Python_Toolkit

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.