gyli / PyWaffle

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

Update to FontAwesome v5 #9

Closed asongtoruin closed 5 years ago

asongtoruin commented 5 years ago

Hello,

Thanks for creating this module, it's really useful and pretty straightforward to use.

One thing I've noticed is that the module currently uses FontAwesome v4.7.0, with the latest version of FA being v5.5.0. It'd be nice to be able to use the latest set of icons and updating the equivalence should be relatively straightforward through the cheatsheet they provide, but the download is now (I believe since 5.0) split into three .otf files - "solid", "regular" and "brands". I see there being two ways to deal with this:

  1. Pick one of the new three to have as the main reference. The "regular" is I think meant to be the most similar to the old icons, but the "solid" is the most complete.
  2. Keep all three and either:
    1. Add an extra parameter to choose which of the three icon sets to use (e.g. icon_set as a string).
    2. Rename the icon lookups to include which set they come from, and ensure the user only uses icons from one set.

I am happy to work on a PR for this based on your preference. I think 2i would work best (and might start looking at implementing it), but will defer to your judgement. There may also be some compatibility issues with name changes, but I think it's worth it for the wider set of icons available.

Thanks,

Adam

gyli commented 5 years ago

Thank you for bringing this up. I will update FontAwesome version shortly.

asongtoruin commented 5 years ago

Above is a PR based around 2i from the above suggestions. It seems to work fairly well though I haven't been able to check it extensively. Here's a chart based on one of the examples given for the module and the new icon set

Example waffle chart using democrat and reuplican icons

Generated using:

fig = plt.figure(
    FigureClass=Waffle, 
    rows=5, 
    values=data, 
    colors=("#232066", "#983D3D", "#DCB732"),
    legend={'loc': 'upper left', 'bbox_to_anchor': (1, 1)},
    icons=['democrat', 'republican', 'person-booth'], icon_size=12, 
    icon_legend=True
)