Skip to contents

In a polar bar plot, each row of data_frame is represented as a wedge mark in polar coordinates.

Usage

px_bar_polar(
  data_frame = NULL,
  r = NULL,
  theta = NULL,
  color = NULL,
  pattern_shape = NULL,
  hover_name = NULL,
  hover_data = NULL,
  custom_data = NULL,
  base = NULL,
  animation_frame = NULL,
  animation_group = NULL,
  category_orders = NULL,
  labels = NULL,
  color_discrete_sequence = NULL,
  color_discrete_map = NULL,
  color_continuous_scale = NULL,
  pattern_shape_sequence = NULL,
  pattern_shape_map = NULL,
  range_color = NULL,
  color_continuous_midpoint = NULL,
  barnorm = NULL,
  barmode = "relative",
  direction = "clockwise",
  start_angle = 90,
  range_r = NULL,
  range_theta = NULL,
  log_r = FALSE,
  title = NULL,
  subtitle = NULL,
  template = NULL,
  width = NULL,
  height = NULL
)

Arguments

data_frame

A data.frame, data.table, list or matrix. Needed for column names to be used in the other arguments; if NULL, a data frame is built from the vectors given in the other arguments.

r

A column name in data_frame, a vector of values, a one-sided formula evaluated in data_frame (e.g. ~ log(pop)), px_constant() or px_range(). Values from this column or vector are used to position marks along the radial axis in polar coordinates.

theta

A column name in data_frame, a vector of values, a one-sided formula evaluated in data_frame (e.g. ~ log(pop)), px_constant() or px_range(). Values from this column or vector are used to position marks along the angular axis in polar coordinates.

color

A column name in data_frame, a vector of values, a one-sided formula evaluated in data_frame (e.g. ~ log(pop)), px_constant() or px_range(). Values from this column or vector are used to assign color to marks.

pattern_shape

A column name in data_frame, a vector of values, a one-sided formula evaluated in data_frame (e.g. ~ log(pop)), px_constant() or px_range(). Values from this column or vector are used to assign pattern shapes to marks.

hover_name

A column name in data_frame, a vector of values, a one-sided formula evaluated in data_frame (e.g. ~ log(pop)), px_constant() or px_range(). Values from this column or vector appear in bold in the hover tooltip.

hover_data

Extra data to show in the hover tooltip: column names (a character vector or a formula such as ~c(a, b)), or a named list with column names as names and values TRUE (default formatting), FALSE (hide the column, e.g. one shown by default), a d3-format string such as ":.3f", a vector of data, or a list of a format string or TRUE and a vector of data.

custom_data

Column names (a character vector or a formula such as ~c(a, b)), or a list of column names, formulas and vectors. Values from these columns are added to the traces' customdata (e.g. for use in Shiny events) without appearing in the hover tooltip.

base

A column name in data_frame, a vector of values, a one-sided formula evaluated in data_frame (e.g. ~ log(pop)), px_constant() or px_range(). Values from this column or vector are used to position the base of the bar.

animation_frame

A column name in data_frame, a vector of values, a one-sided formula evaluated in data_frame (e.g. ~ log(pop)), px_constant() or px_range(). Values from this column or vector are used to assign marks to animation frames.

animation_group

A column name in data_frame, a vector of values, a one-sided formula evaluated in data_frame (e.g. ~ log(pop)), px_constant() or px_range(). Values from this column or vector are used to provide object-constancy across animation frames: rows with matching animation_groups will be treated as if they describe the same object in each frame.

category_orders

Named list mapping column names to the order of their values in axes, legends and facets, e.g. list(day = c("Thur", "Fri", "Sat", "Sun")). By default values appear in the order first encountered, or in level order for factors.

labels

Named character vector or list mapping column names to the labels to use for axis titles, legend entries and hover text, e.g. c(gdpPercap = "GDP per capita").

color_discrete_sequence

Character vector of colors, e.g. px_colors$qualitative$Set1. Values of color are assigned colors in order (cycling), unless set in color_discrete_map. Defaults to the template's colorway.

color_discrete_map

Named character vector or list mapping values of color to colors, overriding color_discrete_sequence. If the values of color are colors, px_identity() (or "identity") uses them directly.

color_continuous_scale

Character vector of colors, e.g. px_colors$sequential$Viridis, or the name of a scale in px_colors. Used when color is numeric. Defaults to the template's sequential colorscale.

pattern_shape_sequence

Strings should define valid plotly.js patterns-shapes. When pattern_shape is set, values in that column are assigned patterns-shapes by cycling through pattern_shape_sequence in the order described in category_orders, unless the value of pattern_shape is a key in pattern_shape_map.

pattern_shape_map

Named character vector or list mapping values of pattern_shape to pattern shapes, overriding pattern_shape_sequence. px_identity() uses the values directly.

range_color

If provided, overrides auto-scaling on the continuous color scale.

color_continuous_midpoint

If set, computes the bounds of the continuous color scale to have the desired midpoint. Setting this value is recommended when using plotly.express.colors.diverging color scales as the inputs to color_continuous_scale.

barnorm

One of "fraction" or "percent". If "fraction", the value of each bar is divided by the sum of all values at that location coordinate. "percent" is the same but multiplied by 100 to show percentages. NULL will stack up all values at each location coordinate.

barmode

One of "group", "overlay" or "relative" In "relative" mode, bars are stacked above zero for positive values and below zero for negative values. In "overlay" mode, bars are drawn on top of one another. In "group" mode, bars are placed beside each other.

direction

One of "counterclockwise" or "clockwise". Default is "clockwise" Sets the direction in which increasing values of the angular axis are drawn.

start_angle

Sets start angle for the angular axis, with 0 being due east and 90 being due north.

range_r

If provided, overrides auto-scaling on the radial axis in polar coordinates.

range_theta

If provided, overrides auto-scaling on the angular axis in polar coordinates.

log_r

If TRUE, the radial axis is log-scaled in polar coordinates.

title

The figure title.

subtitle

The figure subtitle.

template

A template name (see template_names()) or a template list. Defaults to default_template().

width

The figure width in pixels.

height

The figure height in pixels.

Value

A go_figure().

Examples

px_data_wind() |> px_bar_polar(r = ~frequency, theta = ~direction, color = ~strength)