Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to interactively make ggplots #86

Open
dgkeyes opened this issue Jun 28, 2024 · 9 comments
Open

Unable to interactively make ggplots #86

dgkeyes opened this issue Jun 28, 2024 · 9 comments
Assignees

Comments

@dgkeyes
Copy link
Member

dgkeyes commented Jun 28, 2024

Video explanation of issue

@OskaratOmni can you please use the code below to make a new R Markdown document and let me know if this works? Here's a video explanation of a couple things to try as well.

---
title: "OMNI Plot"
author: "David Keyes"
date: "2024-06-28"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r}
library(tidyverse)
library(omni)
```

```{r}
xx = runif(100, 1, 100)

d_data = data.frame(
  x = xx,
  y = .5 * xx + 2
)

ggplot(d_data, aes(x, y)) +
  geom_point() +
  theme_omni()
```
@dgkeyes
Copy link
Member Author

dgkeyes commented Jun 28, 2024

Also, the video recording of our last call is here.

@OskaratOmni
Copy link
Collaborator

Hey @dgkeyes
I just tried this both ways - with and without theme_omni and going to the console and inline.

In all cases when I call theme_omni() i only get a blank square (inline or in the viewer).

I just uploaded a video showing this as well. I know its weird behavior so it might help to see it with your own eyes. :-)

One other thing I tried is adding library(ragg) to the packages and that didn't seem to make a difference.

@OskaratOmni
Copy link
Collaborator

@dgkeyes , I uploaded a second video. Now if I switch global settings back to default, from AGG, on the backend graphics device, it works.

I find this really puzzling but wanted you to see that.

@dgkeyes
Copy link
Member Author

dgkeyes commented Jun 28, 2024

Ok, so just to summarize:

With AGG set as the backend graphics device in RStudio:

  • When knitting, all plots show up fine
  • When working interactively in RStudio, plots without theme_omni() preview fine
  • When working interactively in RStudio, plots with theme_omni() don't show up at all

With the default backend graphics device:

  • When working interactively in RStudio, all plots (with and without theme_omni()) preview fine
  • When knitting, you get warning messages (and I'm pretty sure the correct font is not displaying)

Is that all accurate?

One other question: what version of RStudio do you have? If it's not the newest version, could you update it and let me know if that changes anything?

@dgkeyes dgkeyes self-assigned this Jun 28, 2024
@OskaratOmni
Copy link
Collaborator

Hey @dgkeyes,
My first thought was 'yes' this is all correct, but I played with it a little more and so this is current as you've written it with one additional wrinkle.
If I set base_family in the them_omni() call to something really basic, like "Arial" the graph will show up interactively with the backend set to AGG. It doesn't show up if it uses Calibri.

It wasn't that long ago that I downloaded fonts, but maybe they get removed at some point during some package downloads? Not sure. But I can double check that.

I am using the current version of R studio.

@dgkeyes
Copy link
Member Author

dgkeyes commented Jul 2, 2024

Can you try using a different font? Try doing theme_omni(base_family = "Times New Roman") and see what happens. I'm working if it's specific to Calibri or something else.

@OskaratOmni
Copy link
Collaborator

Hey @dgkeyes I have tried it with Times New Roman and Arial, and in both cases it works interactively.
And it seems to display them with the correct fonts when I have backend set to AGG. (the fonts look the same interactively when i have backend set to default).

With backend set to AGG if I try to make a figure with Calibri I got this message ONE time:
Warning message:
In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database

When I knit, it shows all kinds of warnings about font family for all three of the fonts I tried (Calibri, Times New Roman, and Arial).
And it looks like the knitted file is not showing the correct font.

Weird, huh?

@dgkeyes
Copy link
Member Author

dgkeyes commented Jul 3, 2024

Ok, this is actually really helpful. It seems that R isn't finding the Calibri font, which explains why this isn't working. Try running this code:

library(tidyverse)
library(systemfonts)

system_fonts() |> 
  filter(str_detect(family, "Calibri"))

That will show whether the systemfonts package finds any fonts named Calibri. The output I get is:

# A tibble: 4 × 9
  path                                                    index name   family style weight width italic monospace
  <chr>                                                   <int> <chr>  <chr>  <chr> <ord>  <ord> <lgl>  <lgl>    
1 /Users/davidkeyes/Library/Fonts/Calibri.ttf                 0 Calib… Calib… Regu… normal norm… FALSE  FALSE    
2 /Users/davidkeyes/Library/Fonts/Calibri Bold Italic.ttf     0 Calib… Calib… Bold… bold   norm… TRUE   FALSE    
3 /Users/davidkeyes/Library/Fonts/Calibri Italic.ttf          0 Calib… Calib… Ital… normal norm… TRUE   FALSE    
4 /Users/davidkeyes/Library/Fonts/Calibri Bold.ttf            0 Calib… Calib… Bold  bold   norm… FALSE  FALSE   

Please paste your output in the issue and we can go from there.

@OskaratOmni
Copy link
Collaborator

I haven't done this yet but I bet it works. All the behavior was suggesting to me that the Calibri font got 'dropped' or uninstalled, perhaps as part of a cycle of package updates or something like that. I'll get back t o you ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants