windrose icon indicating copy to clipboard operation
windrose copied to clipboard

plot_windrose should provide a "by" parameter

Open s-celles opened this issue 10 years ago • 3 comments

When feeding plot_windrose with a DataFrame with columns: speed, direction, year_month, passing a parameter like by='year_month' should plot several plots on same figure (subplots).

by = 'year_month'  # same as 'month' or 'year'
df[by] = df.index.map(lambda dt: (dt.year, dt.month))

similar to http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.hist.html https://github.com/pydata/pandas/blob/39d567ec0fcbcaa75d531657412e61f3f274931a/pandas/tools/plotting.py

So it will help to show if major direction of wind (for example) changed over the time.

An other interesting feature could be to animate plot. see https://github.com/scls19fr/windrose/issues/11

http://nbviewer.ipython.org/github/scls19fr/windrose/blob/master/windrose_sample_poitiers_csv.ipynb

Run unit test using

$ nosetests tests.test_windrose:test_plot_by -s -v

s-celles avatar Jun 19 '15 10:06 s-celles

Might be useful to define a shape (number of rows and number of columns)

import math

def shape_from(n):
    sqrt_n = math.sqrt(n)

    Ncol = math.ceil(sqrt_n)
    Nrow = math.ceil(n / Ncol)

    return(Nrow, Ncol)

for n in range(1, 20+1):
    sh = shape_from(n)
    print(n , sh, sh[0]*sh[1], sh[0]*sh[1]-n)

s-celles avatar Jul 07 '15 19:07 s-celles

ToDo : several pages (figures)

see also http://matplotlib.org/examples/pylab_examples/multipage_pdf.html

s-celles avatar Jul 07 '15 19:07 s-celles

https://github.com/scls19fr/windrose/blob/master/samples/example_pdf_by.py

only scatter plot are supported

windrose_2011 windrose_2012 windrose_2013 windrose_2014 windrose_2015

s-celles avatar Aug 27 '15 09:08 s-celles