Can not use my custom font with plotly
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported difference between the showtext/font.add setup in ggplot and the ggplotly(p) %>% layout(font=t) example. Start at the ggplotly and layout(font=t) entry points, and investigate how the custom family is passed to the rendered chart. Done means the Proxima Nova font renders in the Plotly output, with a regression check for the example if the project has a suitable test location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- plotly, r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100