ly_text {rbokeh}R Documentation

Add a "text" layer to a Bokeh figure

Description

Add a "text" layer to a Bokeh figure

Usage

ly_text(fig, x, y = NULL, text = NULL, color = NULL, alpha = NULL,
  angle = NULL, data = figure_data(fig), x_offset = NULL,
  y_offset = NULL, font = NULL, font_size = NULL, font_style = NULL,
  align = NULL, baseline = NULL, legend = TRUE, hov_color = NULL,
  hov_alpha = NULL, ns_color = NULL, ns_alpha = NULL, sel_color = NULL,
  sel_alpha = NULL, lgroup = NULL, lname = NULL)

Arguments

fig

Figure to modify.

x

The x coordinates of text anchors.

y

The y coordinates of text anchors.

text

Text values to render.

color

Text color values for the text.

alpha

Text alpha values for the text.

angle

Angle to rotate the text in radians.

data

An optional data frame, providing the source for inputs x, y, text, and other glyph properties.

x_offset

Offset values to apply to the x-coordinates.

y_offset

Offset values to apply to the y-coordinates.

font

Text font values for the text.

font_size

Text font size values for the text.

font_style

Text font style values for the text ("normal", "italic", "bold").

align

Text align values for the text. One of ("left", "right", "center").

baseline

Text baseline values for the text. One of ("top", "middle", "bottom", "alphabetic", "hanging").

legend

Either a logical specifying not to plot a legend for this layer (FALSE) or a string indicating the name of the legend entry for this layer. Note that when mapping plot attributes to variables in data, a legend is automatically created and does not need to be specified. See "Mapped plot attributes and legends" below.

hov_color

Text color values for the text when hovered.

hov_alpha

Text alpha values for the text when hovered.

ns_color

Text color values for the text when not selected.

ns_alpha

Text alpha values for the text when not selected.

sel_color

Text color values for the text when selected.

sel_alpha

Text alpha values for the text when selected.

lgroup

Layer group.

lname

Layer name.

Mapped plot attributes and legends

When specifying an input data frame for a layer through the data argument, columns of data can be used to specify various plot attributes such as color, etc. For example, with ly_points(..., data = iris, color = Species), the Species variable is used to determine how to color the points. Here, Species is "mapped" to the color attribute. Both continuous and categorical variables can be mapped. In the case of continuous variables, the range is cut into slices and attributes are applied to each interval. The mapping from the values of the variable to the actual plot attributes is determined based on the theme. When attributes are mapped, legend entries are automatically created for the mappings (when possible).

See Also

Other layer functions: ly_annular_wedge, ly_annulus, ly_arc, ly_bar, ly_bezier, ly_boxplot, ly_contour, ly_crect, ly_curve, ly_density, ly_hist, ly_image_url, ly_image, ly_lines, ly_multi_line, ly_oval, ly_patch, ly_points, ly_polygons, ly_quadratic, ly_quantile, ly_ray, ly_rect, ly_segments, ly_wedge

Examples

figure(title = "Periodic Table", data = elements,
  xgrid = FALSE, ygrid = FALSE, xlab = "", ylab = "",
  xlim = as.character(1:18), ylim = c("   ", "  ", " ", as.character(7:1)),
  height = 700, width = 1200) %>%
  ly_crect(cat_offset(group, group_offset), period, 0.9, 0.9,
    color = group_block, fill_alpha = 0.6, legend = FALSE,
    hover = list(name, atomic_number, group_block, atomic_mass,
      electronic_configuration)) %>%
  ly_text(cat_offset(group, sym_offset), period, text = symbol,
    font_style = "bold", font_size = "15pt",
    align = "left", baseline = "middle") %>%
  ly_text(cat_offset(group, sym_offset), cat_offset(period, 0.3), text = atomic_number_p,
    font_size = "9pt", align = "left", baseline = "middle") %>%
  ly_text(cat_offset(group, sym_offset), cat_offset(period, -0.2), text = name,
    font_size = "6pt", align = "left", baseline = "middle") %>%
  ly_text(cat_offset(group, sym_offset), cat_offset(period, -0.35), text = atomic_mass,
    font_size = "6pt", align = "left", baseline = "middle") %>%
  x_axis(axis = axis_spec(visible = FALSE)) %>%
  y_axis(axis = axis_spec(visible = FALSE))

[Package rbokeh version 0.6.3 Index]