- 积分
- 9511
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2017-6-25
- 最后登录
- 1970-1-1
|
发表于 2024-5-6 09:25:38
|
显示全部楼层
本帖最后由 墨家大宝 于 2024-5-6 09:28 编辑
- import pandas as pd
- import numpy as np
- import matplotlib.pyplot as plt
- from matplotlib.colors import ListedColormap, BoundaryNorm
- from matplotlib.font_manager import FontProperties
- from matplotlib.gridspec import GridSpec
- cmap = ListedColormap(['black', 'blue'])
- cmap.set_over('red')
- norm = BoundaryNorm([0, 4, 8], 2)
- font = FontProperties(fname=r"C:\Windows\Fonts\simsun.ttc")
- barb_increments = {
- 'half': 2,
- 'full': 4,
- 'flag': 20
- }
- fig = plt.figure(figsize=(15, 10), constrained_layout=True)
- gs = GridSpec(10, 1, figure=fig)
- ax = fig.add_subplot(gs[:-1])
- ax.barbs(t_mesh, z_mesh, u.T, v.T, ((u**2+v**2)**0.5).T, length=7, barb_increments=barb_increments,
- norm=norm, cmap=cmap)
- ax.set_xlabel('时间(mm-dd: hh)', font=font, fontsize=15)
- ax.set_ylabel('高度(m)', font=font, fontsize=15)
- ax.set_yticks(u.columns)
- ax.set_title(xlsx_path[:-5], font='simsun', fontsize=20)
- ax = fig.add_subplot(gs[-1])
- ax.barbs(legend, np.zeros_like(legend), ((legend**2)**0.5), length=7, barb_increments=barb_increments,
- norm=norm, cmap=cmap)
- for x, lg in enumerate(legend):
- ax.text(x+0.1, 0, f'{lg}', verticalalignment='center')
- ax.set_xlim(-2, 7)
- ax.text(-1.5, 0, '图例(m/s)', font=font, verticalalignment='center', fontsize=15)
- ax.axis('off')
复制代码
|
|