MetPy:站位图对比

MetPy: Station plot contrast

我想知道是否可以在站点图上添加某种文本阴影,以在覆盖其他字段时增加它们的对比度。当覆盖在可见卫星图像上时,我很难找到效果很好的颜色

这是我目前得到的:

stationplot_al = StationPlot(ax, data_als.lon.values, data_als.lat.values, clip_on=True,
                      transform=ccrs.PlateCarree(), fontsize=30)
stationplot_al.plot_parameter('NW', temp_al_c, color='mediumvioletred', weight='demibold')
stationplot_al.plot_parameter('SW', td_al_c, color='mediumvioletred', weight='demibold')
stationplot_al.plot_parameter('NE', data_als.mslp, formatter=lambda v: format(10 * v, '.0f')[-3:],color='orangered',fontsize=32, weight='demibold')
stationplot_al.plot_symbol('C', cf_al_all, sky_cover,color='mediumslateblue')
stationplot_al.plot_barb(u_al, v_al,length=11,linewidth=3.5,barbcolor='mediumslateblue')

您可以使用 matplotlib 中的一项名为 path effects. 的功能 路径效果允许向文本、线条等绘制的路径添加一些渲染效果。可以选择使用阴影,但我认为对于这种情况,大纲可以解决问题:

import matplotlib.patheffects as mpatheffects

outline = [mpatheffects.withStroke(linewidth=1, foreground='black')]
stationplot_al.plot_parameter('NW', temp_al_c, color='mediumvioletred',
                              weight='semibold', path_effects=outline)

请注意,matplotlib 希望在 path_effects 参数中传递一个效果列表。您可以使用 linewidthforeground 参数分别控制轮廓的宽度和颜色。