MetPy:站图对比

时间:2018-08-09 18:33:39

标签: python metpy

我想知道是否有可能在站点图上添加某种文本阴影以增加它们在覆盖其他字段时的对比度。找到覆盖在可见卫星图像

上的颜色时,我很难找到合适的颜色

这是我到目前为止所得到的:

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')

1 个答案:

答案 0 :(得分:1)

您可以使用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参数分别控制轮廓的宽度和颜色。