plotly / plotly/plotly.R

Can not use my custom font with plotly

未关闭
#2,117 1 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
R
星标
2.7k
派生
641
PR 合并指标
30 天内没有已合并 PR

描述

I am trying to use a custom font with plotly but it does not work althoug it does work with ggplot. Is there a way to solve this?
You can download the font here: https://freefontsfamily.com/proxima-nova-font-family-free-download/

This is the ggplot example that does work:

library(dplyr)
library(ggplot2)
library(plotly)
library(showtext)
font.add("Proxima Nova", "ProximaNova.otf")


df <- data.frame(x = c(1,2,3), y = c(2,3,4))

my_theme_ggplot <-
    ggplot2::theme_bw() +
    ggplot2::theme(
      plot.title = element_text(hjust = 0.5),
      text=element_text(size=16,  family="Proxima Nova")
      )

p <- df %>% ggplot(aes(x = x, y = y)) + 
  geom_line() +
  ggtitle("Title", ) +
  labs(y= "Date", x = "Y Data") +
  my_theme_ggplot

p

This is the plotly example that does not work

df <- data.frame(x = c(1,2,3), y = c(2,3,4))
t <- list(
  family = "Proxima Nova",
  size = 14)

p <- df %>% ggplot(aes(x = x, y = y)) + 
  geom_line() +
  ggtitle("Title", ) +
  labs(y= "Date", x = "Y Data") 

ggplotly(p) %>% layout(font=t)

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

复现 ggplot 中的 showtext/font.add 设置与 ggplotly(p) %>% layout(font=t) 示例之间报告的差异。从 ggplotly 和 layout(font=t) 入口点开始,调查自定义字体族如何传递到渲染后的图表中。如果项目有合适的测试位置,则为该示例添加回归检查;当 Proxima Nova 字体在 Plotly 输出中正确渲染时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
plotly, r
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。