Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

FigureFactory - Punchcard plot

Inspired by
http://stackoverflow.com/questions/20044359/punchcard-plot-in-r
and
http://stackoverflow.com/questions/42820823/r-plotly-preserving-appearance-of-two-legends-when-converting-ggplot2-with-ggpl

I wrote a Python function which can create similar plots, e.g.
https://plot.ly/~MaxPeters/358/
https://plot.ly/~MaxPeters/360/
https://plot.ly/~MaxPeters/362/

e.g. the last plot is created by
y_len = 28 data = dict(x=[i for i in range(1, y_len + 1)], y=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'], value = [random.randrange(-5,10) for i in range(7 * y_len)] ) d, l = punch_card(data['x'], data['y'], data['value'], max_size=20, marker_symbol='square', equal_size_markers=True) plotly.offline.iplot(d, l)
Two questions:
a) is there any interest in adding it to Plotly’s FigureFactory?
b) if yes, how do you write tests for such a function?

It’s a great suggestion and would definitely be welcome. Please take a look at this FigureFactory-in-progress for an idea of how tests are implemented:
https://github.com/plotly/plotly.py/pull/731

@jack: thanks!

Here’s a notebook which should demonstrate how the graphs look and work.
https://plot.ly/~MaxPeters/382/import-pandas-as-pd-import-random-import/

@jack: Did you have time to look at the notebook?

@MaxPeters I did - it looks nice! We don’t have time to add it ourselves as a Figure Factory to the Python library right now, but we’re working on a guide for contributors who want to add their own FF’s officially.
One suggestion is you may want to set layout['hovermode'] = closest for the hover effect.