Description Usage Arguments Value Examples
Create a scatter plot from a data frame through ggplotly
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
dt |
data.frame containing the data to plot. |
x |
Value on the x axis. |
y |
Value on the y axis. |
groups |
Name of the column containing the different groups. |
faceted |
If TRUE (default), each group will be plotted separately. |
scales |
From ggplot2::facet_wrap: Should scales be 'fixed', 'free', or free in one dimension ('free_x', 'free_y'). Default is 'fixed'. |
show_trend |
If TRUE, adds a ggplot2::geom_smooth() line to the plot. |
trend_method |
The method ggplot2::geom_smooth will use. Default is 'loess', which is a local polynomial regression fit |
ggtheme |
ggplot2 theme function to apply. Default is ggplot2::theme_minimal. |
x_axis_label |
Label for the x axis. |
y_axis_label |
Label for the y axis. |
plot_palette |
Character vector of hex codes specifying the colors to use on the plot. |
plot_palette_generator |
Palette from the viridis package, used in case plot_palette is unspecified or insufficient for the number of colors required. |
static |
If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of an interactive ggplotly chart. Default is FALSE. |
A plotly-ized version of a grouped ggplot scatter plot.
1 2 3 4 5 6 7 8 9 10 11 12 | make_scatterplot(dt = ggplot2::mpg,
x = 'hwy',
y = 'cty',
groups = 'manufacturer',
faceted = FALSE)
make_scatterplot(dt = ggplot2::mpg,
x = 'hwy',
y = 'cty',
groups = 'manufacturer',
faceted = TRUE,
scales = 'free')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.