gyli / PyWaffle

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

How to arrange the filling order as from top to bottom when using new-line? #22

Closed ReichYang closed 2 years ago

ReichYang commented 2 years ago

Hi. I want to use the new-line arrangement for my plot.

This is what's shown in the documentation.

fig = plt.figure( FigureClass=Waffle, columns=10, values=[30, 16, 4], block_arranging_style='new-line', vertical=True )

image

However, as you can see, for the orange ones, if they have to span multiple rows and cannot span multiple rows, the plot will try to fill out the last row first, leaving the top row of the category incomplete. Is there a way to reverse it so that within each category, the top rows get filled out first then the bottom rows and if multiple rows cannot be filled the last row will be incomplete instead of the first row.

gyli commented 2 years ago

Hi! By default it is plotting each category from bottom left to top right, that's why you are seeing [30, 16, 4] in bottom to top direction. So to make the tail blocks at the "last rows" (top to bottom direction), you can simply flip the plot by specifying starting_location='NW'.

fig = plt.figure(
FigureClass=Waffle,
columns=10,
values=[30, 16, 4],
block_arranging_style='new-line',
vertical=True,
starting_location='NW'
)

This section might be helpful: https://pywaffle.readthedocs.io/en/latest/examples/block_shape_spacing_location_direction_and_style.html#where-to-start-first-block