View source: R/render_contours.R
render_contours | R Documentation |
Adds 3D contours to the current scene, using the heightmap of the 3D surface.
render_contours(
heightmap = NULL,
zscale = 1,
levels = NA,
nlevels = NA,
linewidth = 3,
color = "black",
palette = NULL,
antialias = FALSE,
offset = 0,
clear_previous = FALSE
)
heightmap |
A two-dimensional matrix, where each entry in the matrix is the elevation at that point. All grid points are assumed to be evenly spaced. |
zscale |
Default '1'. The ratio between the x and y spacing (which are assumed to be equal) and the z axis. For example, if the elevation levels are in units of 1 meter and the grid values are separated by 10 meters, 'zscale' would be 10. |
levels |
Default 'NA'. Automatically generated with 10 levels. This argument specifies the exact height levels of each contour. |
nlevels |
Default 'NA'. Controls the auto-generation of levels. If levels is length-2, this will automatically generate 'nlevels' breaks between 'levels[1]' and 'levels[2]'. |
linewidth |
Default '3'. The line width. |
color |
Default 'black'. Color of the line. |
palette |
Default 'NULL'. Overrides 'color'. Either a function that returns a color palette of 'n' colors, or a character vector with colors that specifies each color manually. |
antialias |
Default 'FALSE'. If 'TRUE', the line with be have anti-aliasing applied. NOTE: anti-aliasing can cause some unpredictable behavior with transparent surfaces. |
offset |
Default '5'. Offset of the track from the surface, if 'altitude = NULL'. |
clear_previous |
Default 'FALSE'. If 'TRUE', it will clear all existing paths. |
#Add contours to the montereybay dataset
if(run_documentation()) {
montereybay %>%
height_shade() %>%
add_shadow(ray_shade(montereybay,zscale=50),0.3) %>%
plot_3d(montereybay, theta = -45, zscale=50)
render_contours(montereybay, zscale = 50, offset = 100)
render_snapshot()
}
if(run_documentation()) {
#Specify the number of levels
render_contours(montereybay, zscale = 50, offset = 100, nlevels = 30,
clear_previous = TRUE)
render_snapshot()
}
if(run_documentation()) {
#Manually specify the breaks with levels
render_contours(montereybay, linewidth = 2, offset = 100, zscale = 50,
levels = seq(-2000, 0, 100), clear_previous = TRUE)
render_snapshot()
}
if(run_documentation()) {
#Use a color palette for the contours
volcano |>
constant_shade() |>
plot_3d(volcano, zscale = 2, solid = FALSE, zoom = 0.8)
palette = grDevices::colorRampPalette(c("red", "purple", "pink"))
render_contours(volcano, offset = 1, palette = palette, zscale = 2, nlevels = 20)
render_snapshot()
}
if(run_documentation()) {
#Render using `render_highquality()` for a neon light effect
render_highquality(light = FALSE,
line_radius = 0.1, sample_method="sobol_blue",
path_material = rayrender::light, ground_size = 0,
path_material_args = list(importance_sample = FALSE,
color = "purple", intensity = 2))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.