MetPy: Station plot contrast
Clash Royale CLAN TAG#URR8PPP
MetPy: Station plot contrast
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')
1 Answer
1
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.
path_effects
linewidth
foreground
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.