Skip to main content

Python Matplotlib, Numpy library to manage wind data, draw windrose (also known as a polar rose plot)

Project description

Latest Version Supported Python versions Wheel format License Development Status Downloads monthly Requirements Status Code Health Codacy Badge Build Status


A windrose, also known as a polar rose plot, is a special diagram for representing the distribution of meteorological datas, typically wind speeds by class and direction. This is a simple module for the matplotlib python library, which requires numpy for internal computation.

Original code forked from: - windrose 1.4 by Lionel Roubeyrie


Option libraries:


A package is available and can be downloaded from PyPi and installed using:

$ pip install windrose

Notebook example :

An IPython (Jupyter) notebook showing this package usage is available at:

Script example :

This example use randoms values for wind speed and direction(ws and wd variables). In situation, these variables are loaded with reals values (1-D array), from a database or directly from a text file (see the “load” facility from the matplotlib.pylab interface for that).

from windrose import WindroseAxes
from matplotlib import pyplot as plt
import as cm
import numpy as np

#Create wind speed and direction variables

ws = np.random.random(500) * 6
wd = np.random.random(500) * 360

A stacked histogram with normed (displayed in percent) results :

ax = WindroseAxes.from_ax(), ws, normed=True, opening=0.8, edgecolor='white')


Another stacked histogram representation, not normed, with bins limits

ax = WindroseAxes.from_ax(), ws, bins=np.arange(0, 8, 1))


A windrose in filled representation, with a controled colormap

ax = WindroseAxes.from_ax()
ax.contourf(wd, ws, bins=np.arange(0, 8, 1),


Same as above, but with contours over each filled region…

ax = WindroseAxes.from_ax()
ax.contourf(wd, ws, bins=np.arange(0, 8, 1),
ax.contour(wd, ws, bins=np.arange(0, 8, 1), colors='black')


###…or without filled regions

ax = WindroseAxes.from_ax()
ax.contour(wd, ws, bins=np.arange(0, 8, 1),, lw=3)


After that, you can have a look at the computed values used to plot the windrose with the ax._info dictionnary : - ax._info['bins'] : list of bins (limits) used for wind speeds. If not set in the call, bins will be set to 6 parts between wind speed min and max. - ax._info['dir'] : list of directions “bundaries” used to compute the distribution by wind direction sector. This can be set by the nsector parameter (see below). - ax._info['table'] : the resulting table of the computation. It’s a 2D histogram, where each line represents a wind speed class, and each column represents a wind direction class.

So, to know the frequency of each wind direction, for all wind speeds, do:, ws, normed=True, nsector=16)
table = ax._info['table']
wd_freq = np.sum(table, axis=0)

and to have a graphical representation of this result :

direction = ax._info['dir']
wd_freq = np.sum(table, axis=0), wd_freq, align='center')
xlabels = ('N','','N-E','','E','','S-E','','S','','S-O','','O','','N-O','')


In addition of all the standard pyplot parameters, you can pass special parameters to control the windrose production. For the stacked histogram windrose, calling help( will give : bar(self, direction, var, **kwargs) method of windrose.WindroseAxes instance Plot a windrose in bar mode. For each var bins and for each sector, a colored bar will be draw on the axes.

Mandatory: - direction : 1D array - directions the wind blows from, North centred - var : 1D array - values of the variable to compute. Typically the wind speeds

Optional: - nsector : integer - number of sectors used to compute the windrose table. If not set, nsectors=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- number of bins, or a sequence of bins variable. If not set, bins=6 between min(var) and max(var). - blowto : bool. If True, the windrose will be pi rotated, to show where the wind blow to (usefull for pollutant rose). - colors : string or tuple - 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 - if cmap == None and colors == None, a default Colormap is used. - edgecolor : string - The string color each edge bar will be plotted. Default : no edgecolor - opening : float - between 0.0 and 1.0, to control the space between each sector (1.0 for no space)

probability density function (pdf) and fitting Weibull distribution

A probability density function can be plot using:

from windrose import WindAxes
ax = WindAxes.from_ax()
bins = np.arange(0, 6 + 1, 0.5)
bins = bins[1:]
ax, params = ax.pdf(ws, bins=bins)


Optimal parameters of Weibull distribution can be displayed using

(1, 1.7042156870194352, 0, 7.0907180300605459)

Functional API

Instead of using object oriented approach like previously shown, some “shortcut” functions have been defined: wrbox, wrbar, wrcontour, wrcontourf, wrpdf. See unit tests.

Pandas support

windrose not only supports Numpy arrays. It also supports also Pandas DataFrame. plot_windrose function provides most of plotting features previously shown.

from windrose import plot_windrose
N = 500
ws = np.random.random(N) * 6
wd = np.random.random(N) * 360
df = pd.DataFrame({'speed': ws, 'direction': wd})
plot_windrose(df, kind='contour', bins=np.arange(0.01,8,1),, lw=3)

Mandatory: - df: Pandas DataFrame with DateTimeIndex as index and at least 2 columns ('speed' and 'direction').

Optional: - kind : kind of plot (might be either, 'contour', 'contourf', 'bar', 'box', 'pdf') - var_name : name of var column name ; default value is VAR_DEFAULT='speed' - direction_name : name of direction column name ; default value is DIR_DEFAULT='direction' - clean_flag : cleanup data flag (remove data points with NaN, var=0) before plotting ; default value is True.

Video export

A video of plots can be exported. See:

Video1 Video2 Video3

Source code

This is just a sample for now. API for video need to be created.


$ python samples/ --help

to display command line interface usage.


You can help to develop this library.


You can submit issues using


You can clone repository to try to fix issues yourself using:

$ git clone

Run unit tests

Run all unit tests

$ nosetests -s -v

Run a given test

$ nosetests tests.test_windrose:test_plot_by -s -v

Install development version

$ python install


$ sudo pip install git+


  • Fork repository

  • Create a branch which fix a given issue

  • Submit pull requests

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

windrose-1.6.tar.gz (14.6 kB view hashes)

Uploaded Source

Built Distribution

windrose-1.6-py2.py3-none-any.whl (16.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page