gyli / PyWaffle

🧇 Make Waffle Charts in Python.
MIT License
578 stars 105 forks source link

Add support for vertical orientation #13

Closed asongtoruin closed 4 years ago

asongtoruin commented 4 years ago

As mentioned in #12 this commit adds support for vertically-oriented plots.. I've tested it a bit with plot_direction and it seems to behave in a sensible manner, e.g.

False_3_SW True_3_SW

You can create a full set of these graphs with

for direction in ('NW', 'SW', 'NE', 'SE'):
    for vertical in [True, False]:
        for rows in [4, 3]:
            fig = plt.figure(
                FigureClass=Waffle, rows=rows, vertical=vertical, plot_direction=direction, values=[5, 3, 2],
                title={
                    'label': f'vertical={vertical}, rows={rows}, plot_direction={direction}',
                    'loc': 'left'
                },
            )
            fig.savefig(f'{vertical}_{rows}_{direction}.png', bbox_inches='tight')
            plt.close('all')
asongtoruin commented 4 years ago

One additional tweak that might be nice to make would be to allow the user to only specify the number of columns required, though I haven't got round to looking at this yet.