You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用NREL的Floris库绘制带右侧侧栏图例的风尾流模拟结果图

Floris尾流模拟可视化添加侧边图例解决方案

你只需要捕获visualize_cut_plane返回的等值面绘图对象,再调用matplotlib的colorbar方法绑定到对应坐标轴即可,修改后的代码如下:

import matplotlib.pyplot as plt
import floris.tools as wfct
# Initialize the FLORIS interface fi
# For basic usage, the florice interface provides a simplified interface to
# the underlying classes
file_dir = '...\example_input.json'
fi = wfct.floris_interface.FlorisInterface(file_dir)

# Calculate wake
fi.calculate_wake()

# Get horizontal plane at default height (hub-height)
hor_plane = fi.get_hor_plane()

# Plot and show
fig, ax = plt.subplots()
# 捕获返回的绘图对象
im = wfct.visualization.visualize_cut_plane(hor_plane, ax=ax)
# 添加侧边图例,label内容可根据需求修改为对应物理量和单位
fig.colorbar(im, ax=ax, label='风速 (m/s)')
plt.show()

补充说明:

  • visualize_cut_plane函数默认返回的是matplotlib的QuadMesh对象,刚好可以作为colorbar的输入参数
  • 如果你需要调整图例的样式、位置、刻度,直接修改fig.colorbar的参数即可,比如添加shrink=0.8参数调整图例高度,添加orientation='horizontal'参数改为水平放置图例

内容的提问来源于stack exchange,提问作者Josue9740

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.15 15:15:04