
# gradient_fill(*generate_data(100), zfunc=None) # original For example, to make the lines have an evenly blurred underside, youĬould use PIL to build an alpha layer which is 1 near the line and 0 near the bottom edge. His method opens to door to many gradient/blur/drop-shadowĮffects. Please note Joe Kington deserves the lion's share of the credit here my sole contribution is zfunc. Xy = np.vstack(, xy,, ])Ĭlip_path = Polygon(xy, facecolor='none', edgecolor='none', closed=True) Im = ax.imshow(z, aspect='auto', extent=, The transparent gradient clipped to just the area beneath the curve. If None, the current pyplot axes will be used.Īdditional arguments are passed on to matplotlib's ``plot`` function.

If None, the color of the line will be used. Plot a line with a linear alpha gradient filled beneath it.įill_color : a matplotlib color specifier (string, tuple) or None It's a touch more work, but there's a method that draws much faster and gives a better visual result: Set the clip path of an image plotted with imshow.ĭef gradient_fill(x, y, fill_color=None, ax=None, **kwargs): pcolormesh is fairly slow to draw and isn't smoothly interpolated.The background of the axes can't be transparent, as there's a filled polygon overlying it.


Most of the previous answers recommend plotting a white polygon over a pcolormesh fill. ), but they recommend a sub-optimal approach. There have been a handful of previous answers to similar questions (e.g.
