Learn R Programming

echarts4r (version 0.2.0)

e_scatter: Scatter

Description

Add scatter serie.

Usage

e_scatter(e, serie, size, bind, symbol_size = 1, scale = e_scale,
  name = NULL, coord_system = "cartesian2d", legend = TRUE,
  y_index = 0, x_index = 0, rm_x = TRUE, rm_y = TRUE, ...)

e_effect_scatter(e, serie, size, bind, symbol_size = 1, scale = e_scale, name = NULL, coord_system = "cartesian2d", legend = TRUE, y_index = 0, x_index = 0, rm_x = TRUE, rm_y = TRUE, ...)

e_scale(x)

e_scatter_(e, serie, size = NULL, bind = NULL, symbol_size = 1, scale = e_scale, name = NULL, coord_system = "cartesian2d", legend = TRUE, y_index = 0, x_index = 0, rm_x = TRUE, rm_y = TRUE, ...)

e_effect_scatter_(e, serie, size = NULL, bind = NULL, symbol_size = 1, scale = e_scale, name = NULL, coord_system = "cartesian2d", legend = TRUE, y_index = 0, x_index = 0, rm_x = TRUE, rm_y = TRUE, ...)

Arguments

e

An echarts4r object as returned by e_charts.

serie

Column name of serie to plot.

size

Column name containing size of points.

bind

Binding between datasets, namely for use of e_brush.

symbol_size

Size of points, either an integer or a vector of length 2, if size is not NULL or missing it is applied as a multiplier to scale.

scale

A function that takes a vector of numeric and returns a vector of numeric of the same length.

name

name of the serie.

coord_system

Coordinate system to plot against, see examples.

legend

Whether to add serie to legend.

y_index

Indexes of x and y axis.

x_index

Indexes of x and y axis.

rm_x, rm_y

Whether to remove x and y axis, only applies if coord_system is not set to cartesian2d.

...

Any other option to pass, check See Also section.

x

A vector of integers or numeric.

Scaling function

defaults to e_scale which is a basic function that rescales size between 1 and 20 for that makes for decent sized points on the chart.

See Also

Additional arguments scatter, Additional arguments for effect scatter

Examples

Run this code
# NOT RUN {
# scaling
e_scale(c(1, 1000))

mtcars %>% 
  e_charts(mpg) %>% 
  e_scatter(wt, qsec)
  
my_scale <- function(x) scales::rescale(x, to = c(2, 50))
  
echart <- mtcars %>% 
  e_charts(mpg) %>% 
  e_scatter(wt, qsec, scale = my_scale)
  
echart

# rescale color too
echart %>% 
  e_visual_map(wt, scale = my_scale)
  
# or
echart %>% 
  e_visual_map(min = 2, max = 50)

# applications
USArrests %>% 
  e_charts(Assault) %>% 
  e_scatter(Murder, Rape) %>% 
  e_effect_scatter(Rape, Murder, y_index = 1) %>% 
  e_grid(index = c(0, 1)) %>% 
  e_tooltip()

iris %>% 
  e_charts_("Sepal.Length") %>% 
  e_scatter_(
    "Sepal.Width", 
    symbol_size = c(8, 2), 
    symbol = "rect"
  ) %>% 
  e_x_axis(min = 4)

quakes %>% 
  e_charts(long) %>% 
  e_geo(
    roam = TRUE,
    boundingCoords = list(
      c(185, - 10),
      c(165, -40)
    )
  ) %>% 
  e_scatter(lat, mag, coord_system = "geo") %>% 
  e_visual_map(min = 4, max = 6.5)
  
# }

Run the code above in your browser using DataLab