Advanced Charts using Plotly

Los ejemplos son tomados de la página oficial de plotly, principalmente se obtienen algunos ejemplos gráficos de plotly.

Librerías

Ternary Contour

Basic Ternary Plot with Markers

Basic Terary Contour Plot

Network Graph

La bae de datos que se usa va en relación al social-network del club de karate de Zachary. El archivo de formato GML se puede recopilar desde aquí.

Parallel Coordinates

Adding Dimensions

Basic Parallel Cordinates Plot

Advanced Parallel Coordinates Plot

Carpet Plot

Para establecer las coordenadas \(x\) e \(y\), se usan los atributos \(x\) e \(y\) . Si se omiten los valores de las coordenadas \(x\), se creará un cheater plot.

Basic Carpet Plot

Set the Coordinates

Add Parameter Values

Para guardar los valores de los parámetros, se utilizan los atributos \(a\) y \(b\).

Add Carpet Axes

Se utiliza la listas de aaxis o baxis para realizar cambios en los ejes.

Style Carpet Axes

Carpet Scatter Plot

Basic Carpet Plot

Add Carpet Scatter Trace

Adding Multiple Traces

Carpet Contour Plot

Basic Carpet Plot

Add Contours

Add Multiple Traces

data <- fromJSON(file="https://raw.githubusercontent.com/bcdunbar/datasets/master/airfoil_data.json")

p <- plot_ly()  %>%
        add_trace(type = "carpet",
                    a = list(1.083, 1.214, 1.344, 1.475, 1.605, 1.736, 1.866, 1.997, 2.128, 2.258, 2.389,
                             2.519, 2.650, 2.780, 2.911, 3.041, 3.172, 3.303, 3.433, 3.564, 3.694, 3.825,
                             3.955, 4.086, 4.217, 4.347, 4.478, 4.608, 4.739, 4.869, 5.000),
                    b = list(0.000, 0.090, 0.180, 0.269, 0.359, 0.449, 0.539, 0.628, 0.718, 0.808, 0.898,
                             0.987, 1.077, 1.167, 1.257, 1.346, 1.436, 1.526, 1.616, 1.705, 1.795, 1.885,
                             1.975, 2.064, 2.154, 2.244, 2.334, 2.424, 2.513, 2.603, 2.693, 2.783, 2.872,
                             2.962, 3.052, 3.142, 3.231, 3.321, 3.411, 3.501, 3.590, 3.680, 3.770, 3.860,
                             3.949, 4.039, 4.129, 4.219, 4.308, 4.398, 4.488, 4.578, 4.668, 4.757, 4.847,
                             4.937, 5.027, 5.116, 5.206, 5.296, 5.386, 5.475, 5.565, 5.655, 5.745, 5.834,
                             5.924, 6.014, 6.104, 6.193, 6.283),
                    x = data[[1]]$x,
                    y = data[[1]]$y,
                      aaxis = list(startlinewidth = 2,
                                    startline = TRUE,
                                      showticklabels = "none",
                                        endline = TRUE,
                                          showgrid = FALSE,
                                            endlinewidth = 2,
                                              smoothing = 0),
                      baxis = list(startline = FALSE,
                                     endline = FALSE,
                                       showticklabels = "none",
                                         smoothing = 0,
                                           showgrid = FALSE)) %>% 
          add_trace(type = 'contourcarpet',
                      z = data[[2]]$z,
                        autocolorscale = FALSE,
                          zmax = 1,
                            name = "Pressure",
                              colorscale = "Viridis",
                                zmin = -8,
                                  colorbar = list(y = 0, 
                                                   yanchor = "bottom", 
                                                    titleside = "right",
                                                      len = 0.75,
                                                        title = "Pressure coefficient, c<sub>p</sub>"),
                                    contours = list(start = -1,
                                                      size = 0.025,
                                                        end = 1.000,
                                                          showlines = FALSE),
                                      line = list(smoothing = 0),
                                        autocontour = FALSE,
                                          zauto = FALSE) %>% 
          add_trace(type = 'contourcarpet',
                      z = data[[3]]$z,
                        opacity = 0.300,
                          showlegend = TRUE,
                            name = "Streamlines",
                              autocontour = TRUE,
                                ncontours = 50,
                                  contours = list(coloring = "none"),
                                    line = list(color = "white", width = 1)) %>%
          add_trace(type = 'contourcarpet',
                      z = data[[4]]$z,
                        showlegend = TRUE,
                          name = "Pressure<br>contours",
                            autocontour = FALSE,
                              line = list(color = "rgba(0, 0, 0, 0.5)", smoothing = 1),
                                contours = list(size = 0.250, 
                                                  start = -4,
                                                    coloring = "none",
                                                      end = 1.000,
                                                        showlines = TRUE)) %>% 
          add_trace(type = 'scatter',
                      x = data[[5]]$x,
                        y = data[[5]]$y,
                          legendgroup = "g1",
                            name = "Surface<br>pressure",
                              mode = "lines",
                                hoverinfo = "skip",
                                  line = list(color = "rgba(255, 0, 0, 0.5)", 
                                                width = 1, 
                                                  shape = "spline",
                                                    smoothing = 1),
                                    fill = "toself",
                                      fillcolor = "rgba(255, 0, 0, 0.2)") %>% 
          add_trace(type = 'scatter',
                      x = data[[6]]$x,
                        y = data[[6]]$y,
                          showlegend = FALSE,
                            legendgroup = "g1",
                              mode = "lines",
                                hoverinfo = "skip",
                                  line = list(color = "rgba(255, 0, 0, 0.3)", width = 1)) %>% 
          add_trace(type = 'scatter',
                      x = data[[7]]$x,
                        y = data[[7]]$y,
                          showlegend = FALSE,
                            legendgroup = "g1",
                              name = "cp",
                                mode = "lines",
                                  line = list(color = "rgba(255, 0, 0, 0.2)", width = 0)) %>%
              layout(xaxis = list(zeroline = FALSE,
                                    scaleratio = 1,
                                      scaleanchor = 'y',
                                        range = c(-3.800,3.800),
                                          showgrid = FALSE),
                      yaxis = list(zeroline = FALSE,
                                     range = c(-1.800,1.800),
                                       showgrid = FALSE),
                        title = "Flow over a Karman-Trefftz airfoil",
                          hovermode = "closest",
                            margin = list(r = 60, b = 40, l = 40, t = 80))
p

Polar Chart

Basic Polar Charts

Basic Polar Charts

Line Polar Charts

Area Polar Charts

Categorical Polar Charts

Polar Charts Directions

Polar Charts Sector

Polar Charts Subplot

Webgl Polar Charts

Legacy Plots

Polar Scatter Chart

Background color

Polar Area Chart

Radar Charts

Basic Radar Charts

Multiple Trace Radar Charts

Referencias

Plotly R Graphing Library | R | Plotly. (2020). Retrieved August 5, 2020, from https://plotly.com/r/