### Streamtube Starting Positions Source: https://plotly.com/r/reference/streamtube Defines the starting coordinates for streamtube traces. ```APIDOC ## Streamtube Starting Positions ### Start Coordinates * **starts** (_Type:_ named list) Defines the starting position of the streamtubes. * **x** (_Type:_ dataframe column, list, vector) Sets the x components of the starting position. * **y** (_Type:_ dataframe column, list, vector) Sets the y components of the starting position. * **z** (_Type:_ dataframe column, list, vector) Sets the z components of the starting position. ``` -------------------------------- ### Basic Dash R App Layout Source: https://plotly.com/r/carpet-contour This snippet shows the essential structure for a Dash R application. It initializes a new Dash app, defines its layout to include a div containing a dccGraph component, and starts the server. Ensure you have the 'dash', 'dashCoreComponents', and 'dashHtmlComponents' libraries installed and a Plotly figure object named 'fig' available. ```r library(dash) library(dashCoreComponents) library(dashHtmlComponents) app <- Dash$new() app$layout( htmlDiv( list( dccGraph(figure=fig) ) ) ) app$run_server(debug=TRUE, dev_tools_hot_load=FALSE) ``` -------------------------------- ### Advanced Animation Example in R Source: https://plotly.com/r/animations This comprehensive example combines data plotting, layout options, animation controls (options, button, slider) for an animated scatter plot using the gapminder dataset. Requires plotly and gapminder libraries. ```r library(plotly) df <- gapminder fig <- df %>% plot_ly( x = ~gdpPercap, y = ~lifeExp, size = ~pop, color = ~continent, frame = ~year, text = ~country, hoverinfo = "text", type = 'scatter', mode = 'markers' ) fig <- fig %>% layout( xaxis = list( type = "log" ) ) fig <- fig %>% animation_opts( 1000, easing = "elastic", redraw = FALSE ) fig <- fig %>% animation_button( x = 1, xanchor = "right", y = 0, yanchor = "bottom" ) fig <- fig %>% animation_slider( currentvalue = list(prefix = "YEAR ", font = list(color="red")) ) fig ``` -------------------------------- ### Initialize ScatterGL Trace Source: https://plotly.com/r/reference/scattergl Initialize a scattergl trace using `plot_ly` or `add_trace`. This is the basic setup for creating scatter plots with the WebGL engine. ```R plot_ly(df, type="scattergl"[, ...]) add_trace(p, type="scattergl"[, ...]) ``` -------------------------------- ### Basic Radar Chart in R Source: https://plotly.com/r/radar-chart Create a simple radar chart with a single trace. Ensure the plotly library is installed and loaded. ```r library(plotly) fig <- plot_ly( type = 'scatterpolar', r = c(39, 28, 8, 7, 28, 39), theta = c('A','B','C', 'D', 'E', 'A'), fill = 'toself' ) fig <- fig %>% layout( polar = list( radialaxis = list( visible = T, range = c(0,50) ) ), showlegend = F ) fig ``` -------------------------------- ### Initialize Volume Trace with plot_ly Source: https://plotly.com/r/reference/volume Initializes a volume trace using the `plot_ly` function. This is the primary way to start creating a volume plot. ```R plot_ly(df, type="volume"[, ...]) ``` -------------------------------- ### Set start position and distance between ticks Source: https://plotly.com/r/axes Use `tick0` and `dtick` to define the starting point and interval for axis ticks. This example sets ticks at intervals of 0.5, starting at 0.25 on the y-axis. ```r library(plotly) data(iris) fig <- iris %>% group_by(Species) %>% do(p=plot_ly(., x = ~Sepal.Width, y = ~Sepal.Length, type = "scatter", opacity = 0.5, mode = "markers", marker = list( color = "blue" ))) %>% subplot(nrows = 1, shareX = TRUE, shareY = TRUE) fig <- fig %>% layout( annotations = list( list( x = 0.16, y = 1, font = list(size = 10), text = "species=setosa", xref = "paper", yref = "paper", xanchor = "center", yanchor = "bottom", showarrow = FALSE ), list( x = 0.5, y = 1, font = list(size = 10), text = "species=versicolor", xref = "paper", yref = "paper", xanchor = "center", yanchor = "bottom", showarrow = FALSE ), list( x = 0.85, y = 1, font = list(size = 10), text = "species=virginica", xref = "paper", yref = "paper", xanchor = "center", yanchor = "bottom", showarrow = FALSE ))) %>%layout(plot_bgcolor='#e5ecf6', xaxis = list( zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff'), xaxis2 = list( zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff'), xaxis3 = list( zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff'), yaxis = list( zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff', tick0=0.25, dtick=0.5) ,showlegend = F) fig ``` -------------------------------- ### Initialize scatterpolargl Trace Source: https://plotly.com/r/reference/scatterpolargl Demonstrates how to initialize a scatterpolargl trace using either `plot_ly` or `add_trace` functions. ```R plot_ly(df, type="scatterpolargl"[, ...]) add_trace(p, type="scatterpolargl"[, ...]) ``` -------------------------------- ### 3D Streamtube Plot with Custom Starts and Segments in R Source: https://plotly.com/r/streamtube-plot Generate a 3D streamtube plot with specified starting positions and maximum displayed segments. This example uses wind data and customizes the 'starts' parameter to define multiple origins for the streamtubes, and 'maxdisplayed' to control segment density. ```r library(plotly) df = read.csv('https://raw.githubusercontent.com/plotly/datasets/master/streamtube-wind.csv') fig <- df %>% plot_ly( type = 'streamtube', x = ~x, y = ~y, z = ~z, u = ~u, v = ~v, w = ~w, starts = list( x = rep(80, 16), y = rep(c(20,30,40,50), 4), z = c(rep(0,4),rep(5,4),rep(10,4),rep(15,4)) ), sizeref = 0.3, showscale = F, maxdisplayed = 3000 ) fig <- fig %>% layout( scene = list( aspectratio = list( x = 2, y = 1, z = 0.3 ) ), margin = list( t = 20, b = 20, l = 20, r = 20 ) ) fig ``` -------------------------------- ### Pie Trace Configuration Source: https://plotly.com/r/reference/pie This section details various attributes for configuring pie traces, including hover templates, meta information, custom data, domain settings, and marker styling. ```APIDOC ## Pie Trace Attributes ### hovertemplate Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using `%{variable}`, for example "y: %{y}" as well as `%{xother}`, `%{_xother}`, `%{_xother_}`, `%{xother_}`. When showing info for several points, "xother" will be added to those with different x positions from the first point. An underscore before or after "(x|y)other" will add a space on that side, only when this field is shown. Numbers are formatted using d3-format's syntax `%{variable:d3-format}`, for example "Price: %{y:$.2f}". Dates are formatted using d3-time-format's syntax `%{variable|d3-time-format}`, for example "Day: %{2019-01-01|%A}". Variables that can't be found will be replaced with the specifier. For example, a template of "data: %{x}, %{y}" will result in a value of "data: 1, %{y}" if x is 1 and y is missing. Variables with an undefined value will be replaced with the fallback value. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, all attributes that can be specified per-point (the ones that are `arrayOk: TRUE`) are available. Finally, the template string has access to variables `label`, `color`, `value`, `percent` and `text`. Anything contained in tag `` is displayed in the secondary box, for example `%{fullData.name}`. To hide the secondary box completely, use an empty tag ``. ### hovertemplatefallback _Parent:_ `data[type=pie]` _Type:_ number or categorical coordinate string _Default:_ `-` Fallback string that's displayed when a variable referenced in a template is missing. If the boolean value 'FALSE' is passed in, the specifier with the missing variable will be displayed. ### meta _Parent:_ `data[type=pie]` _Type:_ number or categorical coordinate string Assigns extra meta information associated with this trace that can be used in various text attributes. Attributes such as trace `name`, graph, axis and colorbar `title.text`, annotation `text` `rangeselector`, `updatemenues` and `sliders` `label` text all support `meta`. To access the trace `meta` values in an attribute in the same trace, simply use `%{meta[i]}` where `i` is the index or key of the `meta` item in question. To access trace `meta` in layout attributes, use `%{data[n[.meta[i]}` where `i` is the index or key of the `meta` and `n` is the trace index. ### customdata _Parent:_ `data[type=pie]` _Type:_ dataframe column, list, vector Assigns extra data each datum. This may be useful when listening to hover, click and selection events. Note that, "scatter" traces also appends customdata items in the markers DOM elements ### domain _Parent:_ `data[type=pie]` _Type:_ named list containing one or more of the keys listed below. * column _Parent:_ `data[type=pie].domain` _Type:_ integer greater than or equal to 0 _Default:_ `0` If there is a layout grid, use the domain for this column in the grid for this pie trace . * row _Parent:_ `data[type=pie].domain` _Type:_ integer greater than or equal to 0 _Default:_ `0` If there is a layout grid, use the domain for this row in the grid for this pie trace . * x _Parent:_ `data[type=pie].domain` _Type:_ list _Default:_ `[0, 1]` Sets the horizontal domain of this pie trace (in plot fraction). * y _Parent:_ `data[type=pie].domain` _Type:_ list _Default:_ `[0, 1]` Sets the vertical domain of this pie trace (in plot fraction). ### automargin _Parent:_ `data[type=pie]` _Type:_ boolean Determines whether outside text labels can push the margins. ### marker _Parent:_ `data[type=pie]` _Type:_ named list containing one or more of the keys listed below. * colors _Parent:_ `data[type=pie].marker` _Type:_ dataframe column, list, vector Sets the color of each sector. If not specified, the default trace color set is used to pick the sector colors. * line _Parent:_ `data[type=pie].marker` _Type:_ named list containing one or more of the keys listed below. * color _Parent:_ `data[type=pie].marker.line` _Type:_ color or array of colors _Default:_ `"#444"` Sets the color of the line enclosing each sector. * width _Parent:_ `data[type=pie].marker.line` _Type:_ number or array of numbers greater than or equal to 0 _Default:_ `0` Sets the width (in px) of the line enclosing each sector. * pattern _Parent:_ `data[type=pie].marker` _Type:_ named list containing one or more of the keys listed below. Sets the pattern within the marker. * bgcolor _Parent:_ `data[type=pie].marker.pattern` ``` -------------------------------- ### Funnelarea Trace Initialization Source: https://plotly.com/r/reference/funnelarea Demonstrates how to initialize a funnelarea trace using `plot_ly` or `add_trace` functions in R. ```APIDOC ## Funnelarea Trace Initialization A `funnelarea` trace is initialized with `plot_ly` or `add_trace`: `plot_ly(df, type="funnelarea"[, ...])` `add_trace(p, type="funnelarea"[, ...])` A funnelarea trace accepts any of the keys listed below. ``` -------------------------------- ### Distplot with Normal Curve Source: https://plotly.com/r/distplot This example shows how to plot a distplot with overlaid normal distribution curves for different groups. It utilizes `ggplot2` for the base plot and `plotly` for interactive visualization. Ensure the `ggplot2` and `plotly` libraries are installed. ```r library(ggplot2) library(plotly) set.seed(1) x1 <- rnorm(200, mean = 0, sd = 1) x2 <- rnorm(200, mean = 0, sd = 1) + 2 group_labels = c('Group 1', 'Group 2') df1 <- data.frame(x1, group_labels[1]) colnames(df1) <- c('x', 'Group') df2 <- data.frame(x2, group_labels[2]) colnames(df2) <- c('x', 'Group') df <- rbind(df1,df2) colnames(df) <- c('x', 'Group') gg <- ggplot(data = df , aes(x=x)) + geom_histogram(aes(y = ..density.., fill=Group),bins = 30, alpha = 0.7)+ geom_density(aes(color=Group))+ geom_rug(aes(color=Group))+ labs(x = '', y = '', title = 'Distplot with Normal Distribution') ggplotly(gg)%>% layout(plot_bgcolor='#e5ecf6', xaxis = list( title='Time', zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff'), yaxis = list( title='Value A', zerolinecolor = '#ffff', zerolinewidth = 2, gridcolor = 'ffff')) ``` -------------------------------- ### layout.transition.ordering Source: https://plotly.com/r/reference/layout Determines the order in which layout and traces smoothly transition during updates. It can be set to 'layout first' or 'traces first'. ```APIDOC ## layout.transition.ordering ### Description Determines whether the figure's layout or traces smoothly transitions during updates that make both traces and layout change. ### Type enumerated, one of ( `"layout first"` | `"traces first"` ) ### Default `"layout first"` ``` -------------------------------- ### Install Plotly R Package from GitHub Source: https://plotly.com/r/getting-started Install the latest development version of the plotly R package from GitHub using the devtools package. Ensure you have devtools installed. ```r devtools::install_github("ropensci/plotly") ``` -------------------------------- ### Create a Basic Gantt Chart in R Source: https://plotly.com/r/gantt This snippet shows how to read data from a CSV, convert date formats, assign colors based on resources, and create a basic Gantt chart by adding traces for each task. ```r library(plotly) # Read in data df <- read.csv("https://cdn.rawgit.com/plotly/datasets/master/GanttChart-updated.csv", stringsAsFactors = F) # Convert to dates df$Start <- as.Date(df$Start, format = "%m/%d/%Y") # Sample client name client = "Sample Client" # Choose colors based on number of resources cols <- RColorBrewer::brewer.pal(length(unique(df$Resource)), name = "Set3") df$color <- factor(df$Resource, labels = cols) # Initialize empty plot fig <- plot_ly() # Each task is a separate trace # Each trace is essentially a thick line plot # x-axis ticks are dates and handled automatically for(i in 1:(nrow(df) - 1)){ fig <- add_trace(fig, x = c(df$Start[i], df$Start[i] + df$Duration[i]), # x0, x1 y = c(i, i), # y0, y1 mode = "lines", line = list(color = df$color[i], width = 20), showlegend = F, hoverinfo = "text", # Create custom hover text text = paste("Task: ", df$Task[i], "
", "Duration: ", df$Duration[i], "days
", "Resource: ", df$Resource[i]), evaluate = T # needed to avoid lazy loading ) } fig ``` -------------------------------- ### pie Traces Configuration Source: https://plotly.com/r/reference/pie Configuration options for pie traces, including text font properties, rotation, scaling, sorting, and UI revision. ```APIDOC ## pie Traces Configuration ### Description Configuration options for pie traces, including text font properties, rotation, scaling, sorting, and UI revision. ### Attributes * **variant** (_Parent:_ `data[type=pie].outsidetextfont`) * _Type:_ enumerated or array of enumerateds, one of (`"normal"` | `"small-caps"` | `"all-small-caps"` | `"all-petite-caps"` | `"petite-caps"` | `"unicase"`) * _Default:_ `"normal"` * Sets the variant of the font. * **weight** (_Parent:_ `data[type=pie].outsidetextfont`) * _Type:_ integer or array of integers between or equal to 1 and 1000 * _Default:_ `normal` * Sets the weight (or boldness) of the font. * **rotation** (_Parent:_ `data[type=pie]`) * _Type:_ angle * _Default:_ `0` * Instead of the first slice starting at 12 o'clock, rotate to some other angle. * **scalegroup** (_Parent:_ `data[type=pie]`) * _Type:_ string * _Default:_ `""` * If there are multiple pie charts that should be sized according to their totals, link them by providing a non-empty group id here shared by every trace in the same group. * **sort** (_Parent:_ `data[type=pie]`) * _Type:_ boolean * _Default:_ `TRUE` * Determines whether or not the sectors are reordered from largest to smallest. * **uirevision** (_Parent:_ `data[type=pie]`) * _Type:_ number or categorical coordinate string * Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: TRUE` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: TRUE}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves. ``` -------------------------------- ### Install Plotly R Package from CRAN Source: https://plotly.com/r/getting-started Use this command to install the plotly R package from CRAN. This may not be the latest version. ```r install.packages("plotly") ``` -------------------------------- ### Update Buttons for Traces and Layout Source: https://plotly.com/r/custom-buttons This example shows how to use the 'update' method with buttons to toggle trace visibility and simultaneously update the chart's title and annotations, demonstrating dynamic data and layout modification. ```r library(plotly) library(quantmod) d <- quantmod::getSymbols("AAPL") df <- data.frame(Date=index(AAPL),coredata(AAPL)) high_annotations <- list( x=df$Date[df$AAPL.High == max(df$AAPL.High)], y=max(df$AAPL.High), xref='x', yref='y', text=paste0('High: $',max(df$AAPL.High)), ax=0, ay=-40 ) low_annotations <- list( x=df$Date[df$AAPL.Low == min(df$AAPL.Low)], y=min(df$AAPL.Low), xref='x', yref='y', text=paste0('Low: $',min(df$AAPL.Low)), ax=0, ay=40 ) # updatemenus component updatemenus <- list( list( active = -1, type= 'buttons', buttons = list( list( label = "High", method = "update", args = list(list(visible = c(FALSE, TRUE)), list(title = "Apple High", annotations = list(c(), high_annotations)))), list( label = "Low", method = "update", args = list(list(visible = c(TRUE, FALSE)), list(title = "Apple Low", annotations = list(low_annotations, c() )))), list( label = "Both", method = "update", args = list(list(visible = c(TRUE, TRUE)), list(title = "Apple", annotations = list(low_annotations, high_annotations)))), list( label = "Reset", method = "update", args = list(list(visible = c(TRUE, TRUE)), list(title = "Apple", annotations = list(c(), c()))))) ) ) fig <- df %>% plot_ly(type = 'scatter', mode = 'lines') fig <- fig %>% add_lines(x=~Date, y=~AAPL.High, name="High", line=list(color="#33CFA5")) fig <- fig %>% add_lines(x=~Date, y=~AAPL.Low, name="Low", line=list(color="#F06A6A")) fig <- fig %>% layout(title = "Apple", showlegend=FALSE, xaxis=list(title="Date"), yaxis=list(title="Price ($)"), updatemenus=updatemenus) fig ``` -------------------------------- ### Format Text Annotations in Plotly R Source: https://plotly.com/r/horizontal-vertical-shapes This example demonstrates how to apply custom formatting, such as color, size, and font family, to text annotations in a Plotly R chart. It builds upon the previous example by adding the `textfont` argument to `add_text`. ```r library(tidyquant) library(plotly) tickers = c("GOOG", "AAPL", "AMZN", "META", "NFLX", "MSFT") for (i in tickers){ getSymbols(i, from = "2018-01-01", to = "2019-12-31")} stock <- data.frame(GOOG$GOOG.Adjusted, AAPL$AAPL.Adjusted, AMZN$AMZN.Adjusted, META$META.Adjusted, NFLX$NFLX.Adjusted, MSFT$MSFT.Adjusted) stock$GOOG.Adjusted <- stock$GOOG.Adjusted/stock$GOOG.Adjusted[1] stock$AAPL.Adjusted <- stock$AAPL.Adjusted/stock$AAPL.Adjusted[1] stock$AMZN.Adjusted <- stock$AMZN.Adjusted/stock$AMZN.Adjusted[1] stock$META.Adjusted <- stock$META.Adjusted/stock$META.Adjusted[1] stock$NFLX.Adjusted <- stock$NFLX.Adjusted/stock$NFLX.Adjusted[1] stock$MSFT.Adjusted <- stock$MSFT.Adjusted/stock$MSFT.Adjusted[1] stock <- data.frame(stock,rownames(stock)) colnames(stock) <- append(tickers,'Dates') hline <- function(y = 0, color = "black") { list( type = "line", x0 = 0, x1 = 1, xref = "paper", y0 = y, y1 = y, line = list(color = color, dash="dot") ) } x <- list( title = "date" ) y <- list( title = "value" ) fig <- plot_ly(stock, type = 'scatter', mode = 'lines')%>% add_trace(x = ~Dates, y = ~GOOG, name = 'GOOG')%>% add_trace(x = ~Dates, y = ~AAPL, name = 'AAPL')%>% add_trace(x = ~Dates, y = ~AMZN, name = 'AMZN')%>% add_trace(x = ~Dates, y = ~META, name = 'META')%>% add_trace(x = ~Dates, y = ~NFLX, name = 'NFLX')%>% add_trace(x = ~Dates, y = ~MSFT, name = 'MSFT')%>% layout(legend=list(title=list(text='company')), plot_bgcolor = "#e5ecf6", shapes = list(list(type = "rect", text = 'decline', fillcolor = "green", line = list(color = "green"), opacity = 0.2, y0 = 0.6, y1 = 2.25, x0 = "2018-10-01", x1 = "2018-12-17"), hline(1)), xaxis = x, yaxis = y)%>% add_text(showlegend = FALSE, x = c("2018-11-10","2019-08-20"), y = c(2.2,0.95), text = c("decline","Jan 1, 2018 baseline"), textfont = list(color = c('#000000','blue'), size = c(20,20), family = c("Open Sans","Times New Roman"))) fig Click to copy ``` -------------------------------- ### Choroplethmapbox Trace Initialization Source: https://plotly.com/r/reference/choroplethmapbox Demonstrates how to initialize a choroplethmapbox trace using either `plot_ly` or `add_trace` functions in R. ```APIDOC ## Initialization A `choroplethmapbox` trace is initialized with `plot_ly` or `add_trace`: ```R plot_ly(df, type="choroplethmapbox"[, ...]) add_trace(p, type="choroplethmapbox"[, ...]) ``` ``` -------------------------------- ### Basic 3D Cone Plot Source: https://plotly.com/r/cone-plot Creates a single 3D cone plot. Ensure the plotly library is installed and loaded. ```r library(plotly) fig <- plot_ly( type= "cone", x= 1, y= 1, z= 1, u= 1, v= 1, w= 0 ) fig <- fig %>% layout( scene= list( camera= list( eye= list(x= -0.76, y= 1.8, z= 0.92) ) ) ) fig ``` -------------------------------- ### layout.scene.xaxis.tickangle Source: https://plotly.com/r/reference/layout/scene Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. ```APIDOC ## layout.scene.xaxis.tickangle ### Description Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. ### Type angle ### Default `"auto"` ### Parent `layout.scene.xaxis` ``` -------------------------------- ### histogram2d Trace Configuration Source: https://plotly.com/r/reference/histogram2d This section details the configuration options for `histogram2d` traces, covering binning strategies, marker properties, and text styling. ```APIDOC ## `histogram2d` Trace Configuration This document details the parameters available for customizing 2D histogram traces, including how to define bins for both x and y axes, set marker properties, and style the text font. ### `data[type=histogram2d]` #### `ybingroup` * **Type**: string * **Default**: `""` * **Description**: Set a group of histogram traces which will have compatible y-bin settings. Using `ybingroup`, `histogram2d` and `histogram2dcontour` traces (on axes of the same axis type) can have compatible y-bin settings. Note that the same `ybingroup` value can be used to set (1D) histogram `bingroup`. #### `ybins` * **Type**: named list * **Description**: Configuration for y-axis binning. * **`end`** * **Type**: number or categorical coordinate string * **Description**: Sets the end value for the y axis bins. The last bin may not end exactly at this value, we increment the bin edge by `size` from `start` until we reach or exceed `end`. Defaults to the maximum data value. Like `start`, for dates use a date string, and for category data `end` is based on the category serial numbers. * **`size`** * **Type**: number or categorical coordinate string * **Description**: Sets the size of each y axis bin. Default behavior: If `nbinsy` is 0 or omitted, we choose a nice round bin size such that the number of bins is about the same as the typical number of samples in each bin. If `nbinsy` is provided, we choose a nice round bin size giving no more than that many bins. For date data, use milliseconds or "M" for months, as in `axis.dtick`. For category data, the number of categories to bin together (always defaults to 1). * **`start`** * **Type**: number or categorical coordinate string * **Description**: Sets the starting value for the y axis bins. Defaults to the minimum data value, shifted down if necessary to make nice round values and to remove ambiguous bin edges. For example, if most of the data is integers we shift the bin edges 0.5 down, so a `size` of 5 would have a default `start` of -0.5, so it is clear that 0-4 are in the first bin, 5-9 in the second, but continuous data gets a start of 0 and bins [0,5), [5,10) etc. Dates behave similarly, and `start` should be a date string. For category data, `start` is based on the category serial numbers, and defaults to -0.5. ### `marker` * **Type**: named list * **Description**: Marker configuration for the histogram. * **`color`** * **Type**: dataframe column, list, vector * **Description**: Sets the aggregation data. ### `textfont` * **Type**: named list * **Description**: Configuration for the text font. * **`color`** * **Type**: color * **Default**: `"auto"` * **`family`** * **Type**: string * **Description**: HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available. * **`lineposition`** * **Type**: flaglist string * **Default**: `"none"` * **Description**: Sets the kind of decoration line(s) with text, such as an "under", "over" or "through" as well as combinations e.g. "under+over", etc. * **Examples**: `"under"`, `"over"`, `"under+over"`, `"under+over+through"`, `"none"` * **`shadow`** * **Type**: string * **Default**: `"none"` * **Description**: Sets the shape and color of the shadow behind text. "auto" places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options. * **`size`** * **Type**: number greater than or equal to 1 * **Default**: `"auto"` * **`style`** * **Type**: enumerated * **Default**: `"normal"` * **Description**: Sets whether a font should be styled with a normal or italic face from its family. * **Values**: `"normal"` | `"italic"` * **`textcase`** * **Type**: enumerated * **Default**: `"normal"` * **Description**: Sets the capitalization of the text. * **Values**: `"normal"` | `"word caps"` | `"upper"` | `"lower"` ``` -------------------------------- ### scattergl Trace Configuration Source: https://plotly.com/r/reference/scattergl Configuration options for scattergl traces, including selection styles, gap handling, fill properties, and hover label customization. ```APIDOC ## scattergl Trace Configuration ### Description Configuration options for scattergl traces, including selection styles, gap handling, fill properties, and hover label customization. ### Parameters #### `selected` Configuration for selected points. - **marker**: Configuration for the marker style of selected points. - **color** (color): Sets the marker color of selected points. - **opacity** (number between 0 and 1): Sets the marker opacity of selected points. - **size** (number >= 0): Sets the marker size of selected points. - **textfont**: Configuration for the text font style of selected points. - **color** (color): Sets the text font color of selected points. #### `unselected` Configuration for unselected points. - **marker**: Configuration for the marker style of unselected points. - **color** (color): Sets the marker color of unselected points, applied only when a selection exists. - **opacity** (number between 0 and 1): Sets the marker opacity of unselected points, applied only when a selection exists. - **size** (number >= 0): Sets the marker size of unselected points, applied only when a selection exists. - **textfont**: Configuration for the text font style of unselected points. - **color** (color): Sets the text font color of unselected points, applied only when a selection exists. #### `connectgaps` (boolean) Determines whether or not gaps (i.e. {nan} or missing values) in the provided data arrays are connected. #### `fill` (enumerated) Sets the area to fill with a solid color. Defaults to "none" unless this trace is stacked, then it gets "tonexty" ("tonextx") if `orientation` is "v" ("h") Use with `fillcolor` if not "none". Possible values: "none", "tozeroy", "tozerox", "tonexty", "tonextx", "toself", "tonext". #### `fillcolor` (color) Sets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available. #### `hoverlabel` Configuration for the hover labels. - **align** (enumerated or array of enumerateds): Sets the horizontal alignment of the text content within hover label box. Has an effect only if the hover label text spans more two or more lines. Possible values: "left", "right", "auto". - **bgcolor** (color or array of colors): Sets the background color of the hover labels for this trace. - **bordercolor** (color or array of colors): Sets the border color of the hover labels for this trace. ``` -------------------------------- ### layout.xaxis.tickangle Source: https://plotly.com/r/reference/layout/xaxis Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. ```APIDOC ## layout.xaxis.tickangle ### Description Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. ### Type angle ### Default "auto" ``` -------------------------------- ### Streamtube Trace Configuration Source: https://plotly.com/r/reference/streamtube Configuration options for streamtube traces, including colorbar, colorscale, and font properties. ```APIDOC ## Streamtube Trace Reference This document outlines the configurable properties for `streamtube` traces in Plotly R. ### `data[type=streamtube].colorbar.title.font.textcase` * **Type**: enumerated, one of (`"normal"` | `"word caps"` | `"upper"` | `"lower"`) * **Default**: `"normal"` * **Description**: Sets whether a font should be styled with a normal or italic face from its family. Sets capitalization of text. It can be used to make text appear in all-uppercase or all-lowercase, or with each word capitalized. ### `data[type=streamtube].colorbar.title.font.variant` * **Type**: enumerated, one of (`"normal"` | `"small-caps"` | `"all-small-caps"` | `"all-petite-caps"` | `"petite-caps"` | `"unicase"`) * **Default**: `"normal"` * **Description**: Sets the variant of the font. ### `data[type=streamtube].colorbar.title.font.weight` * **Type**: integer between or equal to 1 and 1000 * **Default**: `normal` * **Description**: Sets the weight (or boldness) of the font. ### `data[type=streamtube].colorbar.title.side` * **Type**: enumerated, one of (`"right"` | `"top"` | `"bottom"`) * **Description**: Determines the location of color bar's title with respect to the color bar. Defaults to "top" when `orientation` if "v" and defaults to "right" when `orientation` if "h". ### `data[type=streamtube].colorbar.title.text` * **Type**: string * **Description**: Sets the title of the color bar. ### `data[type=streamtube].colorbar.x` * **Type**: number * **Description**: Sets the x position with respect to `xref` of the color bar (in plot fraction). When `xref` is "paper", defaults to 1.02 when `orientation` is "v" and 0.5 when `orientation` is "h". When `xref` is "container", defaults to "1" when `orientation` is "v" and 0.5 when `orientation` is "h". Must be between "0" and "1" if `xref` is "container" and between "-2" and "3" if `xref` is "paper". ### `data[type=streamtube].colorbar.xanchor` * **Type**: enumerated, one of (`"left"` | `"center"` | `"right"`) * **Description**: Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the "left", "center" or "right" of the color bar. Defaults to "left" when `orientation` is "v" and "center" when `orientation` is "h". ### `data[type=streamtube].colorbar.xpad` * **Type**: number greater than or equal to 0 * **Default**: `10` * **Description**: Sets the amount of padding (in px) along the x direction. ### `data[type=streamtube].colorbar.xref` * **Type**: enumerated, one of (`"container"` | `"paper"`) * **Default**: `"paper"` * **Description**: Sets the container `x` refers to. "container" spans the entire `width` of the plot. "paper" refers to the width of the plotting area only. ### `data[type=streamtube].colorbar.y` * **Type**: number * **Description**: Sets the y position with respect to `yref` of the color bar (in plot fraction). When `yref` is "paper", defaults to 0.5 when `orientation` is "v" and 1.02 when `orientation` is "h". When `yref` is "container", defaults to 0.5 when `orientation` is "v" and 1 when `orientation` is "h". Must be between "0" and "1" if `yref` is "container" and between "-2" and "3" if `yref` is "paper". ### `data[type=streamtube].colorbar.yanchor` * **Type**: enumerated, one of (`"top"` | `"middle"` | `"bottom"`) * **Description**: Sets this color bar's vertical position anchor This anchor binds the `y` position to the "top", "middle" or "bottom" of the color bar. Defaults to "middle" when `orientation` is "v" and "bottom" when `orientation` is "h". ### `data[type=streamtube].colorbar.ypad` * **Type**: number greater than or equal to 0 * **Default**: `10` * **Description**: Sets the amount of padding (in px) along the y direction. ### `data[type=streamtube].colorbar.yref` * **Type**: enumerated, one of (`"container"` | `"paper"`) * **Default**: `"paper"` * **Description**: Sets the container `y` refers to. "container" spans the entire `height` of the plot. "paper" refers to the height of the plotting area only. ### `data[type=streamtube].autocolorscale` * **Type**: boolean * **Default**: `TRUE` * **Description**: Determines whether the colorscale is a default palette (`autocolorscale: TRUE`) or the palette determined by `colorscale`. In case `colorscale` is unspecified or `autocolorscale` is TRUE, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed. ### `data[type=streamtube].colorscale` * **Type**: colorscale * **Description**: Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `cmin` and `cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Blackbody,Bluered,Blues,Cividis,Earth,Electric,Greens,Greys,Hot,Jet,Picnic,Portland,Rainbow,RdBu,Reds,Viridis,YlGnBu,YlOrRd. ### `data[type=streamtube].showscale` * **Type**: boolean * **Description**: Determines whether a color bar is displayed for this trace. ``` -------------------------------- ### Basic sf Plotting with plot_ly Source: https://plotly.com/r/maps-sf Use `plot_ly` to create a basic map from sf objects. Ensure the 'sf' package is installed. ```r library(plotly) library(sf) nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE) fig <- plot_ly(nc) fig ```