render_title | R Documentation |
Adds a title with optional styling and a title bar to an image.
The image can be previewed or saved to a file. Supports both the grid
-based
method and (deprecated) magick
package for rendering the title.
render_title(
image,
title_text = "",
title_size = 30,
title_offset = rep(title_size/2, 2),
title_lineheight = 1,
title_color = "black",
title_font = "Arial",
title_style = "plain",
title_bar_color = NA,
title_bar_alpha = 0.5,
title_bar_width = NULL,
title_position = NA,
title_just = "left",
use_magick = FALSE,
filename = NULL,
preview = FALSE
)
image |
Image filename or 3-layer RGB array. Specifies the image to process. |
title_text |
Default |
title_size |
Default |
title_offset |
Default |
title_lineheight |
Default |
title_color |
Default |
title_font |
Default |
title_style |
Default |
title_bar_color |
Default |
title_bar_alpha |
Default |
title_bar_width |
Default |
title_position |
Default |
title_just |
Default |
use_magick |
Default |
filename |
Default |
preview |
Default |
A 3-layer RGB array of the processed image if filename = NULL
and preview = FALSE
.
Otherwise, writes the image to the specified file or displays it if preview = TRUE
.
The use_magick
parameter and all functionality tied to the magick
package are
planned for deprecation. It is recommended to use the grid
-based method for
future compatibility.
if(run_documentation()){
#Plot the dragon
render_title(dragon, preview = TRUE, title_text = "Dragon", title_size=20)
}
if(run_documentation()){
#That's hard to see--let's add a title bar:
render_title(dragon, preview = TRUE, title_text = "Dragon", title_size=20,
title_bar_color="white")
}
if(run_documentation()){
#Change the width of the bar:
render_title(dragon, preview = TRUE, title_text = "Dragon", title_size=20,
title_bar_color="white", title_offset = c(8,8))
}
if(run_documentation()){
#The width of the bar will also automatically adjust for newlines:
render_title(dragon, preview = TRUE, title_text = "Dragon\n(Blue)", title_size=20,
title_bar_color="white")
}
if(run_documentation()){
#Change the color and title color:
render_title(dragon, preview = TRUE, title_text = "Dragon", title_size=20,
title_bar_color="red", title_color = "white")
}
if(run_documentation()){
#Change the transparency:
render_title(dragon, preview = TRUE, title_text = "Dragon",
title_size=20, title_bar_alpha = 0.8,
title_bar_color="red", title_color = "white")
}
if(run_documentation()){
#Read directly from a file
temp_image = tempfile(fileext = ".png")
ray_write_image(dragon, temp_image)
render_title(temp_image, preview = TRUE, title_text = "Dragon",
title_size=20, title_bar_alpha = 0.8,
title_bar_color="red", title_color = "white")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.