问题描述
我想在Jupyter笔记本中制作的Plotly图中使用外部字体。
在How do I set custom CSS for my IPython/IHaskell/Jupyter Notebook?中,我创建了一个单元格,添加了我从Google字体页面获取的Poppins字体。
%%html
<style>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
</style>
接下来以简单的Plotly图为例,我尝试在下一个Jupyter代码单元格中使用Poppins字体
# https://plotly.com/python/figure-labels/
import plotly.graph_objects as go
fig = go.figure()
fig.add_trace(go.Scatter(
x=list(range(10)),y=[n**2 for n in range(10)]
))
fig.update_layout(
title="My Plot Title",font=dict(
family="Poppins,monospace",# only this part should matter
size=20
)
)
fig.show()
在Chrome开发工具中,似乎%% HTML单元无法加载字体,因为没有调用googleapis网址。
我正在运行自己的Littlest Jupyter Hub实例,因此我也考虑制作一个custom.css
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)