laserson / squarify

Pure Python implementation of the squarify treemap layout algorithm
Other
297 stars 37 forks source link

allow to change labelsize in plot #14

Closed angelaheumann closed 5 years ago

angelaheumann commented 5 years ago

Based on

https://stackoverflow.com/questions/40207784/how-to-edit-the-label-font-sizes-on-building-a-treemap-with-squarify-in-python/53590473#53590473

I would suggest allowing to pass the size of the labels.

laserson commented 5 years ago

Thanks for the contribution! One thing I am hesitant about is that you specially call out labelsize but there are potentially many properties that one would want to set. I see three alternatives that might be more general:

  1. Pass the kwargs into ax.text as well. I am not certain, but I suspect this will not cause any problems with the ax.bar. Then you can pass whatever properties you want.
  2. Take an explicit dictionary argument into the plot function that will be passed into the ax.text function call.
  3. The plot function is somewhat of a convenience. If you look at the code, you'll see it's quite easy to generate your own plot. You could also consider just calling the MPL API directly to generate your plots.
angelaheumann commented 5 years ago
  1. -> does not work because ax.bar does not know fontsize and throws the following error: Unknown property fontsize
  2. -> should be the best way, but passing two dictionary arguments at the same time causes conflicts (kwargs bar & kwargs text).
  3. Is fine for me, but changing the text is an important feature for plotting complex treemaps.

Any ideas?

laserson commented 5 years ago

My preference would be to go for option 2. Instead of the plot function taking **kwargs, you can have it take bar_kwargs=None and text_kwargs=None.

angelaheumann commented 5 years ago

-> Updated

Tested:

laserson commented 5 years ago

Thanks for the contribution, @angelaheumann!!