gpt4 book ai didi

python - 使用 Altair 和 Jupyter 绘图时如何在轴标签中显示希腊字母?

转载 作者:太空宇宙 更新时间:2023-11-03 15:50:14 30 4
gpt4 key购买 nike

如何在 Altair 中写希腊字母?我需要为轴标签使用一些符号。我正在使用 Jupyter 笔记本

最佳答案

您可以使用 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'
)

产生: plot with x-axis having Greek characters

关于python - 使用 Altair 和 Jupyter 绘图时如何在轴标签中显示希腊字母?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47338568/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com