如何用牛郎星书写希腊字母?我需要使用一些符号来表示轴标签。我用的是Jupyter笔记本
发布于 2018-04-28 13:16:03
通过在轴中使用所需符号的Greek Unicode,可以在轴中显示希腊字母。
工作示例:
import altair as alt
from vega_datasets import data
unicode_gamma = '\u03b3'
# for the notebook only (not for JupyterLab) run this command once per session
alt.renderers.enable('notebook')
iris = data.iris()
alt.Chart(iris).mark_point().encode(
x=alt.X('petalLength', axis=alt.Axis(title=' Alpha Beta Gamma \u03b1 \u03b2 '+ unicode_gamma)),
y='petalWidth',
color='species'
)这会产生:

发布于 2018-08-22 00:56:02
Altair不像matplotlib那样支持Latex数学,因为Vega只支持Unicode字符。
昨天,当我尝试将使用matplotlib生成的旧图转换为Altair时,我遇到了同样的问题,标签/标题不能正确显示。上面的答案很棒,只是想补充一下,一些常见的上标/下标也有它们的unicodes,可以传递给Altair/Vega。
查看这个精彩的答案:How to find the unicode of the subscript alphabet?
https://stackoverflow.com/questions/47338568
复制相似问题