I am wondering if it is possible to add some sort of a text shadow to the station plots to increase their contrast when overlaid on other fields. I am having a lot of trouble finding colors that work well when overlaid on visible satellite imagery
This is what I've gotten so far:
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')
You can, using a feature from matplotlib called path effects. Path effects allow adding some rendering effects to the paths drawn out by text, lines, etc. There is an option to use a shadow, but I think for this case outlining does the trick:
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)
Note that matplotlib expects to be passed a list of effects in the path_effects
parameter. You can use the linewidth
and foreground
parameters to control the width and color of the outline, respectively.