huracanpy.plot.fancyline#
- huracanpy.plot.fancyline(x, y, colors=None, vmin=None, vmax=None, cmap=None, clip_colors=False, linewidths=None, wmin=None, wmax=None, wrange=(1, 5), clip_linewidths=True, alphas=None, amin=None, amax=None, arange=(0, 1), clip_alphas=True, linestyles=None, ax=None, transform=None, autoscale=True)[source]#
A line plot of x vs y that can show extra information by having a variable color, linewidth, alpha, linestyle, or any combination of the four.
For variable color set a vmin, vmax, and cmap (similar to pcolormesh/contourf)
>>> fancyline(x, y, colors=z, vmin=0, vmax=10, cmap="viridis")
For variable linewidth, set a wmin, wmax, and wrange. Like with vmin/vmax, wmin/wmax specify the data values for the smallest and largest linewidth with variables outside that range being clipping to wmin/wmax. The wrange specifies the range of linewidths that you actually want to display
>>> fancyline(x, y, linewidths=z, wmin=0, wmax=10, wrange=(1, 5))
For a variable alpha, set an amin, amax, and arange
>>> fancyline(x, y, alphas=z, amin=0, amax=10, arange=(0, 1))
For a variable linestyle, pass an array of linestyles specified as strings. e.g. to show whether z is above a threshold
>>> linestyles = ["--" if value < 5 else "-" for value in z] >>> fancyline(x, y, linestyles=linestyles)
https://matplotlib.org/stable/gallery/lines_bars_and_markers/multicolored_line
- Parameters:
x (array_like) – The points to plot
y (array_like) – The points to plot
colors (array_like or str, optional) – The data used to set the colors along the line or a string of the color to set the line to a uniform color
vmin (scalar, optional) – The bounding values of the colors array for the colormap. If not set, will use the min and max of the colors array
vmax (scalar, optional) – The bounding values of the colors array for the colormap. If not set, will use the min and max of the colors array
cmap (str, optional) – Specify the colormap. Will default to the matplotlib default (viridis)
clip_colors (bool, default=False) – Clips values outside vmin/vmax to vmin/vmax. The default of False is the standard behaviour for matplotlib and sets the colours to the outside colors from the colormap
linewidths (array_like or scalar, optional) – The data used to set the width along the line or a single value for the whole line
wmin (scalar, optional) – The bounding values for the linewidths. If not set, will use the min and max of the linewidths array
wmax (scalar, optional) – The bounding values for the linewidths. If not set, will use the min and max of the linewidths array
wrange (tuple, default=(1, 5)) – The range of linewidths to map the data to
clip_linewidths (bool, default=True) – Clips values outside wmin/wmax to wmin/wmax. Unlike clip_colors, this is set to True by default because negative linewidths are interpreted as positive and to avoid very large linewidths on the figure.
alphas (array_like or scalar, optional) – The data used to set the alpha along the line or a single value for the whole line
amin (float, optional) – The bounding values for the alphas. If not set, will use the min and max of the alphas array
amax (float, optional) – The bounding values for the alphas. If not set, will use the min and max of the alphas array
arange (tuple, default=(0, 1)) – The range of alphas to map the data to
clip_alphas (bool, default=True) – Clips values outside amin/amax to amin/amax. Unlike clip_colors, this is set to True by default because alphas outside the range 0-1 will raise an error
linestyles (array_like or str, optional)
ax (matplotlib.axes.Axes or cartopy.mpl.geoaxes.GeoAxes, optional) – The axes to add the line to. If not given, it will be added to the most recent axes
transform (cartopy coordinate reference system, optional) – If the axes being drawn on are GeoAxes then the data will be converted from the data coordinates, given by the transform, to the projection coordinates. If a transform is not given, then cartopy.crs.Geodetic will be used with default arguments
autoscale (bool, default=True) – Determines whether to call ax.autoscale() after adding the lines to the plot because the x/y limits are not automatically adjusted otherwise. If you are overlaying the line on an existing plot you may want to avoid doing this by setting to False.
- Returns:
The plotted LineCollection. Required as argument to matplotlib.pyplot.colorbar
- Return type: