Why are certain characters not rendering properly in ggplot2 with installed font?

58 Views Asked by At

I have installed Jeko font using the show_text library, however certain characters are not rendering properly when plotted with ggplot2.

Here is my current code:

library(ggthemes)
library(showtext)
library(quantmod)
library(ggplot2)
library(scales)

getSymbols(c("AAPL"))
AAPL <- data.frame(DATE = index(AAPL), AAPL[,6], row.names = NULL)
tail(AAPL)




font_add("jeko",  regular = "C://Users//username//Downloads//Jeko-Demo-Fonts//Jeko Demo Fonts//JekoDEMO-Medium.otf",
         italic = "C://Users//username//Downloads//Jeko-Demo-Fonts//Jeko Demo Fonts//JekoDEMO-MediumItalic.otf",
         bold = "C://Users//username//Downloads//Jeko-Demo-Fonts//Jeko Demo Fonts//JekoDEMO-ExtraBold.otf")
font_families()

showtext_auto()
p = ggplot(AAPL, aes(x=DATE, y = AAPL.Adjusted))+
  geom_line()+
  scale_x_date(breaks = seq.Date(from = as.Date('2017-01-01'), to = as.Date('2024-01-01'), by = '1 year'), 
               labels = scales::date_format('%Y'), limits = as.Date(c('2017-01-01', Sys.Date())))+
  scale_y_continuous(labels = scales::dollar_format(prefix = "$"))+
  labs(title = "Apple Inc. (AAPL)", y = "")+
  theme_clean(base_family = "jeko")+
  theme(legend.title= element_blank(),
        legend.position = "bottom")

## On-screen device
x11()
print(p)

Which gives me this plot: https://i.stack.imgur.com/VLoaT.png

I'm trying to find out why parenthesis and dollar signs aren't rendering properly in the plot and how to fix it if possible.

0

There are 0 best solutions below