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

The position or size of the window cannot be infinite #3

Open
xiayh17 opened this issue Jan 11, 2021 · 0 comments
Open

The position or size of the window cannot be infinite #3

xiayh17 opened this issue Jan 11, 2021 · 0 comments

Comments

@xiayh17
Copy link

xiayh17 commented Jan 11, 2021

Hi,

Thank you for this project, which improves the way rgl is used and makes things easier.
But recently I ran into such a problem.

library(MBA)
library(dplyr)
library(tidyr)
library(tibble)
library(ggplot2)
library(ggrgl)

x=attitude$rating
y=attitude$complaints
z=attitude$privileges
# a b-spline surface
spline <- mba.surf(data.frame(x,y,z),100,100)

# plot with rgl
library(rgl)
open3d(scale=c(1/diff(range(x)),1/diff(range(y)),1/diff(range(z))))
with(spline$xyz,surface3d(x,y,z,alpha=.2))
points3d(x,y,z)
title3d(xlab="rating",ylab="complaints",zlab="privileges")
axes3d()

# plot with ggrgl follow the demo 
# https://coolbutuseless.github.io/package/ggrgl/articles/demo-volcano.html#using-geom_tile_z-to-render-volcano-data

p <- spline$xyz %>%
  
  # Data wrangling
  as_tibble() %>%
  rowid_to_column(var="X") %>%
  gather(key="Y", value="Z", -1) %>%
  
  # Change Y to numeric
  mutate(Y=as.numeric(gsub("V","",Y))) %>%
  
  # Viz
  ggplot(aes(X, Y, fill= Z, colour = Z, z = Z)) + 
  geom_tile_z(extrude = TRUE) +
  theme_ggrgl() + 
  theme(legend.position="none") + 
  scale_fill_viridis_c(option = 'A') +
  scale_colour_viridis_c(option = 'A') +
  coord_equal() +
  labs(
    title = "ggrgl::geom_tile_z() rendering volcano",
    subtitle = "with {devoutrgl}"
  )


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Render Plot in 3d with {devoutrgl}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
devoutrgl::rgldev(fov = 30, view_angle = -30)
p
invisible(dev.off())

here is error reported
Error in grid.Call.graphics(C_setviewport, vp, TRUE) :
The position or size of the window cannot be infinite
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(diff(sort(x))) : no non-missing arguments to min; returning Inf
4: Removed 300 rows containing missing values (geom_tile_z).

I guess the NA value maybe the reason for the error, But NA is included in the dataset, and rgl's result is correct. Do you have any suggestions or opinions on this?

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

1 participant