API

Windrose for matplotlib

class windrose.WindAxes(*args, **kwargs)
static from_ax(ax=None, fig=None, figsize=(8, 8), *args, **kwargs)
pdf(var, bins=None, Nx=100, bar_color='b', plot_color='g', Nbins=10, *args, **kwargs)

Draw probability density function and return Weibull distribution parameters

set(*, adjustable=<UNSET>, agg_filter=<UNSET>, alpha=<UNSET>, anchor=<UNSET>, animated=<UNSET>, aspect=<UNSET>, autoscale_on=<UNSET>, autoscalex_on=<UNSET>, autoscaley_on=<UNSET>, axes_locator=<UNSET>, axisbelow=<UNSET>, box_aspect=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, facecolor=<UNSET>, frame_on=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, mouseover=<UNSET>, navigate=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, prop_cycle=<UNSET>, rasterization_zorder=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, subplotspec=<UNSET>, title=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, xbound=<UNSET>, xlabel=<UNSET>, xlim=<UNSET>, xmargin=<UNSET>, xscale=<UNSET>, xticklabels=<UNSET>, xticks=<UNSET>, ybound=<UNSET>, ylabel=<UNSET>, ylim=<UNSET>, ymargin=<UNSET>, yscale=<UNSET>, yticklabels=<UNSET>, yticks=<UNSET>, zorder=<UNSET>)

Set multiple properties at once.

Supported properties are

Properties:

adjustable: {‘box’, ‘datalim’} agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None anchor: (float, float) or {‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, …} animated: bool aspect: {‘auto’, ‘equal’} or float autoscale_on: bool autoscalex_on: unknown autoscaley_on: unknown axes_locator: Callable[[Axes, Renderer], Bbox] axisbelow: bool or ‘line’ box_aspect: float or None clip_box: .Bbox clip_on: bool clip_path: Patch or (Path, Transform) or None facecolor or fc: color figure: .Figure frame_on: bool gid: str in_layout: bool label: object mouseover: bool navigate: bool navigate_mode: unknown path_effects: .AbstractPathEffect picker: None or bool or float or callable position: [left, bottom, width, height] or ~matplotlib.transforms.Bbox prop_cycle: unknown rasterization_zorder: float or None rasterized: bool sketch_params: (scale: float, length: float, randomness: float) snap: bool or None subplotspec: unknown title: str transform: .Transform url: str visible: bool xbound: unknown xlabel: str xlim: (bottom: float, top: float) xmargin: float greater than -0.5 xscale: unknown xticklabels: unknown xticks: unknown ybound: unknown ylabel: str ylim: (bottom: float, top: float) ymargin: float greater than -0.5 yscale: unknown yticklabels: unknown yticks: unknown zorder: float

class windrose.WindAxesFactory

Factory class to create WindroseAxes or WindAxes

static create(typ, ax=None, *args, **kwargs)

Create

Mandatory:

Parameters
  • typ (string, 'windroseaxes' or 'windaxes') –

    Type of axes to create
    • windroseaxes : a WindroseAxes axe

    • windaxe : a WindAxes axe

  • ax (matplotlib.Axes, optional) – A matplotlib axe

class windrose.WindroseAxes(*args, **kwargs)

Create a windrose axes

bar(direction, var, **kwargs)

Plot a windrose in bar mode. For each var bins and for each sector, a colored bar will be draw on the axes.

Parameters
  • direction (1D array) – directions the wind blows from, North centred

  • var (1D array) – values of the variable to compute. Typically the wind speeds.

  • nsector (integer, optional) – number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinals points.

  • bins (1D array or integer, optional) – number of bins, or a sequence of bins variable. If not set, bins=6 between min(var) and max(var).

  • blowto (bool, optional.) – if True, the windrose will be pi rotated, to show where the wind blow to (useful for pollutant rose).

  • colors (string or tuple, optional) – one string color (‘k’ or ‘black’), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified.

  • cmap (a cm Colormap instance from matplotlib.cm, optional.) – if cmap == None and colors == None, a default Colormap is used.

  • edgecolor (string, optional) – The string color each edge box will be plotted. Default : no edgecolor

  • opening (float, optional) – between 0.0 and 1.0, to control the space between each sector (1.0 for no space)

  • calm_limit (float, optional) – Calm limit for the var parameter. If not None, a centered red circle will be draw for representing the calms occurrences and all data below this value will be removed from the computation.

box(direction, var, **kwargs)

Plot a windrose in proportional box mode. For each var bins and for each sector, a colored box will be draw on the axes.

Parameters
  • direction (1D array) – directions the wind blows from, North centred

  • var (1D array) – values of the variable to compute. Typically the wind speeds

  • nsector (integer, optional) – number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinals points.

  • bins (1D array or integer, optional) – number of bins, or a sequence of bins variable. If not set, bins=6 between min(var) and max(var).

  • blowto (bool, optional) – If True, the windrose will be pi rotated, to show where the wind blow to (useful for pollutant rose).

  • colors (string or tuple, optional) – one string color (‘k’ or ‘black’), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified.

  • cmap (a cm Colormap instance from matplotlib.cm, optional) – if cmap == None and colors == None, a default Colormap is used.

  • edgecolor (string, optional) – The string color each edge bar will be plotted. Default : no edgecolor

  • calm_limit (float, optional) – Calm limit for the var parameter. If not None, a centered red circle will be draw for representing the calms occurrences and all data below this value will be removed from the computation.

clear()

Clear the current axes

contour(direction, var, **kwargs)

Plot a windrose in linear mode. For each var bins, a line will be draw on the axes, a segment between each sector (center to center). Each line can be formatted (color, width, …) like with standard plot pylab command.

Parameters
  • direction (1D array) – directions the wind blows from, North centred

  • var (1D array) – values of the variable to compute. Typically the wind speeds.

  • nsector (integer, optional) – number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinals points.

  • bins (1D array or integer, optional) – number of bins, or a sequence of bins variable. If not set, bins=6, then bins=linspace(min(var), max(var), 6)

  • blowto (bool, optional) – If True, the windrose will be pi rotated, to show where the wind blow to (useful for pollutant rose).

  • colors (string or tuple, optional) – one string color (‘k’ or ‘black’), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified.

  • cmap (a cm Colormap instance from matplotlib.cm, optional) – if cmap == None and colors == None, a default Colormap is used.

  • calm_limit (float, optional) – Calm limit for the var parameter. If not None, a centered red circle will be draw for representing the calms occurrences and all data below this value will be removed from the computation.

  • kwargs (others) – Any supported argument of matplotlib.pyplot.plot

contourf(direction, var, **kwargs)

Plot a windrose in filled mode. For each var bins, a line will be draw on the axes, a segment between each sector (center to center). Each line can be formatted (color, width, …) like with standard plot pylab command.

Parameters
  • direction (1D array) – directions the wind blows from, North centred

  • var (1D array) – values of the variable to compute. Typically the wind speeds

  • nsector (integer, optional) – number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinals points.

  • bins (1D array or integer, optional) – number of bins, or a sequence of bins variable. If not set, bins=6, then bins=linspace(min(var), max(var), 6)

  • blowto (bool, optional) – If True, the windrose will be pi rotated, to show where the wind blow to (useful for pollutant rose).

  • colors (string or tuple, optional) – one string color (‘k’ or ‘black’), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified.

  • cmap (a cm Colormap instance from matplotlib.cm, optional) – if cmap == None and colors == None, a default Colormap is used.

  • calm_limit (float, optional) – Calm limit for the var parameter. If not None, a centered red circle will be draw for representing the calms occurrences and all data below this value will be removed from the computation.

  • kwargs (others) – Any supported argument of matplotlib.pyplot.plot

static from_ax(ax=None, fig=None, rmax=None, figsize=(8, 8), rect=None, *args, **kwargs)

Return a WindroseAxes object for the figure fig.

legend(loc='lower left', decimal_places=1, units=None, **kwargs)

Sets the legend location and her properties.

Parameters
  • loc (int, string or pair of floats, default: 'lower left') – see matplotlib.pyplot.legend.

  • decimal_places (int, default 1) – The decimal places of the formatted legend

  • units (str, default None) –

  • isaxes (boolean, default True) – whether this is an axes legend

  • prop (FontProperties(size='smaller')) – the font property

  • borderpad (float) – the fractional whitespace inside the legend border

  • shadow (boolean) – if True, draw a shadow behind legend

  • labelspacing (float, 0.005) – the vertical space between the legend entries

  • handlelenght (float, 0.05) – the length of the legend lines

  • handletextsep (float, 0.02) – the space between the legend line and legend text

  • borderaxespad (float, 0.02) – the border between the axes and legend edge

  • kwarg – Every other kwarg argument supported by matplotlib.pyplot.legend

name = 'windrose'
set(*, adjustable=<UNSET>, agg_filter=<UNSET>, alpha=<UNSET>, anchor=<UNSET>, animated=<UNSET>, aspect=<UNSET>, autoscale_on=<UNSET>, autoscalex_on=<UNSET>, autoscaley_on=<UNSET>, axes_locator=<UNSET>, axisbelow=<UNSET>, box_aspect=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, facecolor=<UNSET>, frame_on=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, legend=<UNSET>, mouseover=<UNSET>, navigate=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, prop_cycle=<UNSET>, radii_angle=<UNSET>, rasterization_zorder=<UNSET>, rasterized=<UNSET>, rgrids=<UNSET>, rlabel_position=<UNSET>, rlim=<UNSET>, rmax=<UNSET>, rmin=<UNSET>, rorigin=<UNSET>, rscale=<UNSET>, rticks=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, subplotspec=<UNSET>, theta_direction=<UNSET>, theta_offset=<UNSET>, theta_zero_location=<UNSET>, thetagrids=<UNSET>, thetalim=<UNSET>, thetamax=<UNSET>, thetamin=<UNSET>, title=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, xbound=<UNSET>, xlabel=<UNSET>, xlim=<UNSET>, xmargin=<UNSET>, xscale=<UNSET>, xticklabels=<UNSET>, xticks=<UNSET>, ybound=<UNSET>, ylabel=<UNSET>, ylim=<UNSET>, ymargin=<UNSET>, yscale=<UNSET>, yticklabels=<UNSET>, yticks=<UNSET>, zorder=<UNSET>)

Set multiple properties at once.

Supported properties are

Properties:

adjustable: {‘box’, ‘datalim’} agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: scalar or None anchor: (float, float) or {‘C’, ‘SW’, ‘S’, ‘SE’, ‘E’, ‘NE’, …} animated: bool aspect: {‘auto’, ‘equal’} or float autoscale_on: bool autoscalex_on: unknown autoscaley_on: unknown axes_locator: Callable[[Axes, Renderer], Bbox] axisbelow: bool or ‘line’ box_aspect: float or None clip_box: .Bbox clip_on: bool clip_path: Patch or (Path, Transform) or None facecolor or fc: color figure: .Figure frame_on: bool gid: str in_layout: bool label: object legend: unknown mouseover: bool navigate: bool navigate_mode: unknown path_effects: .AbstractPathEffect picker: None or bool or float or callable position: [left, bottom, width, height] or ~matplotlib.transforms.Bbox prop_cycle: unknown radii_angle: unknown rasterization_zorder: float or None rasterized: bool rgrids: tuple with floats rlabel_position: number rlim: unknown rmax: float rmin: float rorigin: float rscale: unknown rticks: unknown sketch_params: (scale: float, length: float, randomness: float) snap: bool or None subplotspec: unknown theta_direction: unknown theta_offset: unknown theta_zero_location: str thetagrids: tuple with floats, degrees thetalim: unknown thetamax: unknown thetamin: unknown title: str transform: .Transform url: str visible: bool xbound: unknown xlabel: str xlim: (bottom: float, top: float) xmargin: float greater than -0.5 xscale: unknown xticklabels: unknown xticks: unknown ybound: unknown ylabel: str ylim: (bottom: float, top: float) ymargin: float greater than -0.5 yscale: unknown yticklabels: unknown yticks: unknown zorder: float

set_legend(**pyplot_arguments)
set_radii_angle(**kwargs)

Set the radii labels angle

windrose.clean(direction, var, index=False)

Remove nan and var=0 values in the two arrays if a var (wind speed) is nan or equal to 0, this data is removed from var array but also from dir array if a direction is nan, data is also removed from both array

windrose.clean_df(df, var='speed', direction='direction')

Remove nan and var=0 values in the DataFrame if a var (wind speed) is nan or equal to 0, this row is removed from DataFrame if a direction is nan, this row is also removed from DataFrame

windrose.histogram(direction, var, bins, nsector, normed=False, blowto=False, total=0)

Returns an array where, for each sector of wind (centred on the north), we have the number of time the wind comes with a particular var (speed, pollutant concentration, …).

Parameters
  • direction (1D array) – directions the wind blows from, North centred

  • var (1D array) – values of the variable to compute. Typically the wind speeds

  • bins (list) – list of var category against we’re going to compute the table

  • nsector (integer) – number of sectors

  • normed (boolean, default False) – The resulting table is normed in percent or not.

  • blowto (boolean, default False) – Normally a windrose is computed with directions as wind blows from. If true, the table will be reversed (useful for pollutantrose)

windrose.plot_windrose(direction_or_df, var=None, kind='contour', var_name='speed', direction_name='direction', by=None, rmax=None, ax=None, **kwargs)

Plot windrose from a pandas DataFrame or a numpy array.

windrose.plot_windrose_df(df, kind='contour', var_name='speed', direction_name='direction', by=None, rmax=None, ax=None, **kwargs)

Plot windrose from a pandas DataFrame.

windrose.plot_windrose_np(direction, var, kind='contour', clean_flag=True, by=None, rmax=None, ax=None, **kwargs)

Plot windrose from a numpy array.

windrose.wrbar(direction, var, ax=None, rmax=None, figsize=(8, 8), **kwargs)

Plot a windrose in bar mode. For each var bins and for each sector, a colored bar will be draw on the axes.

Parameters
  • direction (1D array) – directions the wind blows from, North centred

  • var (1D array) – values of the variable to compute. Typically the wind speeds.

  • nsector (integer, optional) – number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinals points.

  • bins (1D array or integer, optional) – number of bins, or a sequence of bins variable. If not set, bins=6 between min(var) and max(var).

  • blowto (bool, optional.) – if True, the windrose will be pi rotated, to show where the wind blow to (useful for pollutant rose).

  • colors (string or tuple, optional) – one string color (‘k’ or ‘black’), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified.

  • cmap (a cm Colormap instance from matplotlib.cm, optional.) – if cmap == None and colors == None, a default Colormap is used.

  • edgecolor (string, optional) – The string color each edge box will be plotted. Default : no edgecolor

  • opening (float, optional) – between 0.0 and 1.0, to control the space between each sector (1.0 for no space)

  • calm_limit (float, optional) – Calm limit for the var parameter. If not None, a centered red circle will be draw for representing the calms occurrences and all data below this value will be removed from the computation.

windrose.wrbox(direction, var, ax=None, rmax=None, figsize=(8, 8), **kwargs)

Plot a windrose in proportional box mode. For each var bins and for each sector, a colored box will be draw on the axes.

Parameters
  • direction (1D array) – directions the wind blows from, North centred

  • var (1D array) – values of the variable to compute. Typically the wind speeds

  • nsector (integer, optional) – number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinals points.

  • bins (1D array or integer, optional) – number of bins, or a sequence of bins variable. If not set, bins=6 between min(var) and max(var).

  • blowto (bool, optional) – If True, the windrose will be pi rotated, to show where the wind blow to (useful for pollutant rose).

  • colors (string or tuple, optional) – one string color (‘k’ or ‘black’), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified.

  • cmap (a cm Colormap instance from matplotlib.cm, optional) – if cmap == None and colors == None, a default Colormap is used.

  • edgecolor (string, optional) – The string color each edge bar will be plotted. Default : no edgecolor

  • calm_limit (float, optional) – Calm limit for the var parameter. If not None, a centered red circle will be draw for representing the calms occurrences and all data below this value will be removed from the computation.

windrose.wrcontour(direction, var, ax=None, rmax=None, figsize=(8, 8), **kwargs)

Plot a windrose in linear mode. For each var bins, a line will be draw on the axes, a segment between each sector (center to center). Each line can be formatted (color, width, …) like with standard plot pylab command.

Parameters
  • direction (1D array) – directions the wind blows from, North centred

  • var (1D array) – values of the variable to compute. Typically the wind speeds.

  • nsector (integer, optional) – number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinals points.

  • bins (1D array or integer, optional) – number of bins, or a sequence of bins variable. If not set, bins=6, then bins=linspace(min(var), max(var), 6)

  • blowto (bool, optional) – If True, the windrose will be pi rotated, to show where the wind blow to (useful for pollutant rose).

  • colors (string or tuple, optional) – one string color (‘k’ or ‘black’), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified.

  • cmap (a cm Colormap instance from matplotlib.cm, optional) – if cmap == None and colors == None, a default Colormap is used.

  • calm_limit (float, optional) – Calm limit for the var parameter. If not None, a centered red circle will be draw for representing the calms occurrences and all data below this value will be removed from the computation.

  • kwargs (others) – Any supported argument of matplotlib.pyplot.plot

windrose.wrcontourf(direction, var, ax=None, rmax=None, figsize=(8, 8), **kwargs)

Plot a windrose in filled mode. For each var bins, a line will be draw on the axes, a segment between each sector (center to center). Each line can be formatted (color, width, …) like with standard plot pylab command.

Parameters
  • direction (1D array) – directions the wind blows from, North centred

  • var (1D array) – values of the variable to compute. Typically the wind speeds

  • nsector (integer, optional) – number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinals points.

  • bins (1D array or integer, optional) – number of bins, or a sequence of bins variable. If not set, bins=6, then bins=linspace(min(var), max(var), 6)

  • blowto (bool, optional) – If True, the windrose will be pi rotated, to show where the wind blow to (useful for pollutant rose).

  • colors (string or tuple, optional) – one string color (‘k’ or ‘black’), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified.

  • cmap (a cm Colormap instance from matplotlib.cm, optional) – if cmap == None and colors == None, a default Colormap is used.

  • calm_limit (float, optional) – Calm limit for the var parameter. If not None, a centered red circle will be draw for representing the calms occurrences and all data below this value will be removed from the computation.

  • kwargs (others) – Any supported argument of matplotlib.pyplot.plot

windrose.wrpdf(var, bins=None, Nx=100, bar_color='b', plot_color='g', Nbins=10, ax=None, rmax=None, figsize=(8, 8), *args, **kwargs)

Draw probability density function and return Weibull distribution parameters

windrose.wrscatter(direction, var, ax=None, rmax=None, figsize=(8, 8), *args, **kwargs)

Draw scatter plot