ContextLab / hypertools

A Python toolbox for gaining geometric insights into high-dimensional data
http://hypertools.readthedocs.io/en/latest/
MIT License
1.83k stars 160 forks source link

support for multibyte character labels #205

Open manybooks opened 6 years ago

manybooks commented 6 years ago

Is there any way to use the multibyte characters as labels? I tried hyp.plot(x, labels=multibyte_characters) but not worked. ( In matplotlib.pyplot, I always use fontproperty )

jeremymanning commented 6 years ago

Thanks for submitting an issue! Can you paste in the error you're encountering? And could you also provide a full snippet that we could use to replicate the error?

manybooks commented 6 years ago

I apologize for confusing you. I didn't get any error. But every multibyte characters are replaced by white square. (The link below is example of matplotlib but it will help you what I'm saying) http://cdn-ak.f.st-hatena.com/images/fotolife/s/sucrose/20130610/20130610000617.png

And my code is as follows.

import hypertools as hyp
import numpy as np

X = np.random.rand(3, 10)
labels = ["いち", "に", "さん"] # these are japanese characters
hyp.plot(X, labels=labels)
jeremymanning commented 6 years ago

Ah, thanks for clarifying. We use matplotlib as our back end renderer, so if the issue is also part of matplotlib we won't be able to address it directly within hypertools. Could you submit an issue to matplotlib as well?

In the mean time, we are also looking into other renderers (plotly and ipyvolume), so I'll leave this issue open until the multibyte character issue is resolved.

manybooks commented 6 years ago

In matplotlib, I can render multibyte charcters by passing fontproperty like this.

import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties

fp = FontProperties(fname='path\to\Fonts\YuGothic.ttf')
plt.text(1, 1, 'にほんご', fontproperties=fp)

So I want you to provide any way to specify fontproperty of matplotlib working in the backend.

jeremymanning commented 6 years ago

@manybooks thanks for the additional info. i've added an issue to add functionality to allow passing arguments to matplotlib through hyp.plot.