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

Can't find theme_border in PEcAn.visualization package #3254

Open
odiche97 opened this issue Feb 9, 2024 · 1 comment
Open

Can't find theme_border in PEcAn.visualization package #3254

odiche97 opened this issue Feb 9, 2024 · 1 comment

Comments

@odiche97
Copy link

odiche97 commented Feb 9, 2024

Bug Description

I want to use the theme_border function for a plot created using ggplot2. I installed the PEcAn package in RStudio using this code:

options(repos = c(
  pecanproject = 'https://pecanproject.r-universe.dev',
  CRAN = 'https://cloud.r-project.org'))

install.packages('PEcAn.all')

When I tried to use theme_border, I got the following error message:

Error in opts(panel.border = theme_border(c("bottom", "left"))) : 
  could not find function "opts"

I also checked the functions in PEcAn.visualization and also noticed that theme_border was not in the packages listed.

ls("package:PEcAn.visualization")
[1] "add_icon"    "ciEnvelope"  "map.output"  "plot_data"   "plot_netcdf" "vwReg"  

To Reproduce:

Use the following code:

df = data.frame( x=c(1,2,3), y=c(4,5,6) )
ggplot(data=df, aes(x=x, y=y)) + geom_point() + theme_bw() +
  opts(panel.border = theme_border(c('bottom','left')) )

Sidenote: I also read that the opts function had been discontinued so I also tried:

df = data.frame( x=c(1,2,3), y=c(4,5,6) )
ggplot(data=df, aes(x=x, y=y)) + geom_point() + theme_bw() +
  theme(panel.border = theme_border(c('bottom','left')) )

which gave me this error:

Error in theme_border(c("bottom", "left")) :  could not find function "theme_border"

Machine:

  • I am using a Windows computer with the RStudio version 2023.12.1+402
@mdietze
Copy link
Member

mdietze commented Feb 14, 2024

Our apologies, that is a small helper function that's not exported because it wasn't intended for general use. The code comes from https://groups.google.com/forum/?fromgroups#!topic/ggplot2/-ZjRE2OL8lE and we borrowed it (with attribution) long ago so can't comment on it's continued support within ggplot2. That said, you should be able to access internal functions by using the namespace an 3 colons (PEcAn.visualization:::theme_border)

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