首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当使用Altair和Jupyter绘图时,如何在Axis标签中显示希腊字母?

当使用Altair和Jupyter绘图时,如何在Axis标签中显示希腊字母?
EN

Stack Overflow用户
提问于 2017-11-17 04:32:16
回答 2查看 1.1K关注 0票数 5

如何用牛郎星书写希腊字母?我需要使用一些符号来表示轴标签。我用的是Jupyter笔记本

EN

回答 2

Stack Overflow用户

发布于 2018-04-28 13:16:03

通过在轴中使用所需符号的Greek Unicode,可以在轴中显示希腊字母。

工作示例:

代码语言:javascript
复制
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'
)

这会产生:

票数 5
EN

Stack Overflow用户

发布于 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?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47338568

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档