Skip to content

Commit 47cb819

Browse files
committed
use NA trick to avoid adding surfacecolor/z to color scale
1 parent 7116695 commit 47cb819

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

demo/sf-plotly-3D-globe.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ empty_axis <- list(
2929
# for centering camera/lighting on the center of the storm paths
3030
xyzmean <- list(x = .41, y = -.71, z = 0.57)
3131

32+
3233
# A 3D globe implemented with 3D lines and a spherical surface
3334
# Note that the globe has a radius of 1, but project the lines with
3435
# a radius of 1.001 so that we appear on top of the surface
@@ -54,11 +55,11 @@ globe <- plot_ly(height = 500) %>%
5455
add_surface(
5556
x = cos(degrees2radians(lon)) * cos(degrees2radians(lat)),
5657
y = sin(degrees2radians(lon)) * cos(degrees2radians(lat)),
57-
# The I() prevents plotly from mapping this value to color
58-
z = I(sin(degrees2radians(lat))),
59-
# NOTE: you can map a value to surfacecolor to encode, say air temp..
60-
# TODO: perhaps there is a better way to specify a constant surfacecolor?
61-
colorscale = list(c(0, "white"), c(1, "white")),
58+
z = sin(degrees2radians(lat)),
59+
# NOTE: you can map a value to surfacecolor to encode, say air temp
60+
# for an example, see https://github.com/cpsievert/Weather_Stuff/blob/master/radiation-plot-3D.R
61+
# But here is a trick to set the surface color to a constant white
62+
surfacecolor = matrix(NA, nrow = nlat, ncol = nlon),
6263
showscale = FALSE, hoverinfo = "skip",
6364
lightposition = xyzmean,
6465
contours = list(

0 commit comments

Comments
 (0)