TutteInstitute / datamapplot

Creating beautiful plots of data maps
MIT License
488 stars 33 forks source link

Error on saving interactive plot to HTML: UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f50d' in position 3366: character maps to <undefined> #26

Open igorkf opened 4 months ago

igorkf commented 4 months ago

Hello. First of all, this library is amazing!

I am trying to save the interactive plot to HTML, but I am getting this error:

UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f50d' in position 3366: character maps to <undefined>

It seems this Unicode char is a LEFT-POINTING MAGNIFYING GLASS: https://www.fileformat.info/info/unicode/char/1f50d/index.htm

And I think this error in happening because I set enable_search=True, which includes a search box with a magnifying glass symbol on it:

plot = datamapplot.create_interactive_plot(
    coords,
    df['group'].values,
    hover_text=hover_data,
    cluster_boundary_polygons=False,
    color_cluster_boundaries=False,
    enable_search=True
)
plot.save('datamapplot.html')
plot

However, when setting enable_search=False, the HTML is saved fine.

P.S.: I am using Windows 10.

lmcinnes commented 4 months ago

Hmm, I have not seen that issue on systems I've used (it seems to accept the magnifying glass just fine). Perhaps I can make the icon/character user settable. In the meantime you can solve the problem by editing these lines in your installation and simply replacing the magnifying glass character with something that will save correctly on your system (just the text "enter search query here" would do for example).

igorkf commented 4 months ago

Hmm, I have not seen that issue on systems I've used (it seems to accept the magnifying glass just fine). Perhaps I can make the icon/character user settable. In the meantime you can solve the problem by editing these lines in your installation and simply replacing the magnifying glass character with something that will save correctly on your system (just the text "enter search query here" would do for example).

Thanks for the quick reply. Just changed the magnifying glass to something like "Search: " and worked fine.

Thanks!