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

create axes limits representative of real plotted areas #3

Open
abubelinha opened this issue Jan 31, 2023 · 2 comments
Open

create axes limits representative of real plotted areas #3

abubelinha opened this issue Jan 31, 2023 · 2 comments

Comments

@abubelinha
Copy link

I've been looking at the examples here.

  • Seems that box colors represent Human Development Index (HDI), and a numeric color scale indicates HDI numeric value of each box.
  • Box areas are proportional to Gross Domestic Product (GDP), but the graph gives no idea of its real value (there are no numeric axes to estimate box areas as their height x width products).

Changing ax.axis('off') to ax.axis('on') we see those numerical scales, but they go from 0 to 100 by default, which is not very realistic:

mpl_extra-100

Ideally, the product of both axis lengths (thus 100 x 100) should be equal to the total summed area of all boxes (which is not 10000 in the example graphs, as US GDP value alone is 15684750).
We cannot use width x height of each box to know the real GDP value for that country.

But we can correct axes x and y upper limits, so their product equals that total area sum of all boxes:

aspect=1.156 # taken from your example
import math
total_area = df['gdp_mil_usd'].sum()
norm_x = math.sqrt(total_area)
norm_y = math.sqrt(total_area)

mpl_extra-corrected-but-different-scales

This way we can calculate any box GDP by its area (width x height).
I think this is useful, so there could be an option to autocalculate norm_x and norm_y this way.

@chenyulue
Copy link
Owner

This is a good suggestion! I'll try to add the feafure when I'm free.

In my opinion, on the other hand, treemap is useful to compare the relative difference between groups, but not to obtain the absolute values. If we want to the absolute values, maybe adding values in the labels is an alternative choice.

Anyway, thanks for your suggestion!

@abubelinha
Copy link
Author

abubelinha commented Feb 8, 2023 via email

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