Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks of a single colour are not always contiguous #20

Closed
cpbl opened this issue Jul 17, 2020 · 11 comments
Closed

Blocks of a single colour are not always contiguous #20

cpbl opened this issue Jul 17, 2020 · 11 comments

Comments

@cpbl
Copy link

cpbl commented Jul 17, 2020

In this example output, the yellow block is split up, unnecessarily:

zf7kX
(from example at https://stackoverflow.com/questions/41400136/how-to-do-waffle-charts-in-python-square-piechart )

Shouldn't the rolling out of blocks go down one column, then up the next, then down the next, and so on, in order to ensure that coloured regions remain contiguous?

@gyli
Copy link
Owner

gyli commented Jul 17, 2020

This is the expected result, as the default drawing direction is from bottom left going up, then going right.
The starting location could be changed through parameter starting_location, and the direction could be changed through vertical. You can find more examples here https://pywaffle.readthedocs.io/en/latest/examples/block_shape_distance_location_and_direction.html

@gyli gyli closed this as completed Jul 17, 2020
@cpbl
Copy link
Author

cpbl commented Jul 17, 2020

Hi @gyli. Thanks for your package.

Those examples do not address the question of keeping colours contiguous. You can consider this a feature request rather than a bug if you like, but I'm saying currently the output doesn't look good. It would look much better if the yellow blocks were contiguous, and I think your code could be fixed to ensure that --- or to give it as another option.

@gyli
Copy link
Owner

gyli commented Jul 17, 2020

I'm sorry that I din't get your point of keeping colors contiguous. If you take a look of the similar example in the README page, it is drawing from upper left to bottom right, while it does not avoid yellow blocks being separated, since there's just not enough blocks.
So in this case, what do you suggest to make yellow blocks being together? Making a new option to force each color starting from a new column maybe?

https://github.com/gyli/PyWaffle/raw/master/examples/readme/title_and_legend.svg

@cpbl
Copy link
Author

cpbl commented Jul 17, 2020

That's not necessary.
But it should draw down the first column, then up the next column, then down the next column, etc.
Then colours would never be broken up.

@gyli
Copy link
Owner

gyli commented Jul 17, 2020

OK, that's also what I mean. I think we can do an option allowing this.

@gyli gyli reopened this Jul 17, 2020
@cpbl cpbl changed the title Contiguous sections are broken up Blocks of a single colour are not always contiguous Jul 17, 2020
@gyli
Copy link
Owner

gyli commented Jul 18, 2020

Just to confirm, is this what you thought? Every color starts from a new column so blocks with same color could be together. I am working on a new option to allow this.
Figure_1

@cpbl
Copy link
Author

cpbl commented Jul 18, 2020

No. That is painted top to bottom on every column.
My suggestion is to alternate directions on each column.

@cpbl
Copy link
Author

cpbl commented Jul 18, 2020

The point is never to jump from the top to the bottom, or bottom to top, when you're painting. Lay down squares by snaking back and forth.

Look at my first example at the top of this Issue.
The last two yellow squares should be at the top of their column, right next to the last yellow square painted in the previous column.

@gyli
Copy link
Owner

gyli commented Jul 18, 2020

I see. That is a good point!

@gyli
Copy link
Owner

gyli commented Jul 20, 2020

@cpbl The feature is added in the latest version 0.6.0. Use parameter block_arranging_style='snake' to enable it.

Doc could be found here https://pywaffle.readthedocs.io/en/latest/examples/block_shape_distance_location_and_direction.html#where-to-start-each-category

Thanks again for this great idea!

@gyli gyli closed this as completed Jul 20, 2020
@cpbl
Copy link
Author

cpbl commented Jul 20, 2020

Nice work, and thank you for this addition and for the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants