Skip to content

Commit d9251fe

Browse files
committed
build of c273a15
0 parents  commit d9251fe

File tree

180 files changed

+42185
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+42185
-0
lines changed

ggplot2/2021-08-04-2D-Histogram.md

Lines changed: 155 additions & 0 deletions
Large diffs are not rendered by default.

ggplot2/2021-08-04-animations.md

Lines changed: 217 additions & 0 deletions
Large diffs are not rendered by default.

ggplot2/2021-08-04-axes.md

Lines changed: 261 additions & 0 deletions
Large diffs are not rendered by default.

ggplot2/2021-08-04-bar-charts.md

Lines changed: 322 additions & 0 deletions
Large diffs are not rendered by default.

ggplot2/2021-08-04-box-plots.md

Lines changed: 254 additions & 0 deletions
Large diffs are not rendered by default.

ggplot2/2021-08-04-bubble-charts.md

Lines changed: 126 additions & 0 deletions
Large diffs are not rendered by default.

ggplot2/2021-08-04-bubble-maps.md

Lines changed: 134 additions & 0 deletions
Large diffs are not rendered by default.

ggplot2/2021-08-04-bubblecloud.md

Lines changed: 194 additions & 0 deletions
Large diffs are not rendered by default.

ggplot2/2021-08-04-bullet-charts.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
description: How to make Bullet Charts in ggplot2 with Plotly.
3+
name: Bullet Charts
4+
permalink: ggplot2/bullet-charts/
5+
thumnail_github: bullet-charts.png
6+
layout: base
7+
language: ggplot2
8+
display_as: financial
9+
page_type: u-guide
10+
order: 8
11+
output:
12+
html_document:
13+
keep_md: true
14+
---
15+
16+
17+
18+
## Default plot
19+
20+
Control colours with `fill` argument inside `fill()`.
21+
22+
23+
``` r
24+
library(plotly)
25+
library(ggplot2)
26+
library(tidyverse)
27+
28+
data <- tibble(
29+
name = "Example",
30+
quant_value = 75,
31+
qualitative = 100
32+
)
33+
34+
p <- data %>%
35+
ggplot(aes(x = quant_value, y = name)) +
36+
geom_col(aes(x = qualitative), fill = "grey") +
37+
geom_col(width = 0.5, fill = "black")
38+
39+
ggplotly(p)
40+
```
41+
42+
<div class="plotly html-widget html-fill-item" id="htmlwidget-f75aaff13a0a203c4b11" style="width:672px;height:480px;"></div>
43+
<script type="application/json" data-for="htmlwidget-f75aaff13a0a203c4b11">{"x":{"data":[{"orientation":"v","width":100,"base":0.55000000000000004,"x":[50],"y":[0.89999999999999991],"text":"qualitative: 100<br />name: Example","type":"bar","textposition":"none","marker":{"autocolorscale":false,"color":"rgba(190,190,190,1)","line":{"width":1.8897637795275593,"color":"transparent"}},"showlegend":false,"xaxis":"x","yaxis":"y","hoverinfo":"text","frame":null},{"orientation":"v","width":75,"base":0.75,"x":[37.5],"y":[0.5],"text":"quant_value: 75<br />name: Example","type":"bar","textposition":"none","marker":{"autocolorscale":false,"color":"rgba(0,0,0,1)","line":{"width":1.8897637795275593,"color":"transparent"}},"showlegend":false,"xaxis":"x","yaxis":"y","hoverinfo":"text","frame":null}],"layout":{"margin":{"t":26.228310502283104,"r":7.3059360730593621,"b":40.182648401826491,"l":66.484018264840202},"plot_bgcolor":"rgba(235,235,235,1)","paper_bgcolor":"rgba(255,255,255,1)","font":{"color":"rgba(0,0,0,1)","family":"","size":14.611872146118724},"xaxis":{"domain":[0,1],"automargin":true,"type":"linear","autorange":false,"range":[-5,105],"tickmode":"array","ticktext":["0","25","50","75","100"],"tickvals":[0,24.999999999999996,50,75,100],"categoryorder":"array","categoryarray":["0","25","50","75","100"],"nticks":null,"ticks":"outside","tickcolor":"rgba(51,51,51,1)","ticklen":3.6529680365296811,"tickwidth":0.66417600664176002,"showticklabels":true,"tickfont":{"color":"rgba(77,77,77,1)","family":"","size":11.68949771689498},"tickangle":-0,"showline":false,"linecolor":null,"linewidth":0,"showgrid":true,"gridcolor":"rgba(255,255,255,1)","gridwidth":0.66417600664176002,"zeroline":false,"anchor":"y","title":{"text":"quant_value","font":{"color":"rgba(0,0,0,1)","family":"","size":14.611872146118724}},"hoverformat":".2f"},"yaxis":{"domain":[0,1],"automargin":true,"type":"linear","autorange":false,"range":[0.40000000000000002,1.6000000000000001],"tickmode":"array","ticktext":["Example"],"tickvals":[1],"categoryorder":"array","categoryarray":["Example"],"nticks":null,"ticks":"outside","tickcolor":"rgba(51,51,51,1)","ticklen":3.6529680365296811,"tickwidth":0.66417600664176002,"showticklabels":true,"tickfont":{"color":"rgba(77,77,77,1)","family":"","size":11.68949771689498},"tickangle":-0,"showline":false,"linecolor":null,"linewidth":0,"showgrid":true,"gridcolor":"rgba(255,255,255,1)","gridwidth":0.66417600664176002,"zeroline":false,"anchor":"x","title":{"text":"name","font":{"color":"rgba(0,0,0,1)","family":"","size":14.611872146118724}},"hoverformat":".2f"},"shapes":[{"type":"rect","fillcolor":null,"line":{"color":null,"width":0,"linetype":[]},"yref":"paper","xref":"paper","x0":0,"x1":1,"y0":0,"y1":1}],"showlegend":false,"legend":{"bgcolor":"rgba(255,255,255,1)","bordercolor":"transparent","borderwidth":1.8897637795275593,"font":{"color":"rgba(0,0,0,1)","family":"","size":11.68949771689498}},"hovermode":"closest","barmode":"relative"},"config":{"doubleClick":"reset","modeBarButtonsToAdd":["hoverclosest","hovercompare"],"showSendToCloud":false},"source":"A","attrs":{"36486878706f":{"x":{},"y":{},"type":"bar"},"3648390801ff":{"x":{},"y":{}}},"cur_data":"36486878706f","visdat":{"36486878706f":["function (y) ","x"],"3648390801ff":["function (y) ","x"]},"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.20000000000000001,"selected":{"opacity":1},"debounce":0},"shinyEvents":["plotly_hover","plotly_click","plotly_selected","plotly_relayout","plotly_brushed","plotly_brushing","plotly_clickannotation","plotly_doubleclick","plotly_deselect","plotly_afterplot","plotly_sunburstclick"],"base_url":"https://plot.ly"},"evals":[],"jsHooks":[]}</script>
44+
45+
46+
47+
48+
## Size of the plot
49+
50+
To make the plot thinner use `ylim` argument inside `coord_cartesian()`.
51+
52+
53+
``` r
54+
library(plotly)
55+
library(ggplot2)
56+
library(tidyverse)
57+
58+
data <- tibble(
59+
name = "Example",
60+
quant_value = 75,
61+
qualitative = 100
62+
)
63+
64+
p <- data %>%
65+
ggplot(aes(x = quant_value, y = name)) +
66+
geom_col(aes(x = qualitative), fill = "grey") +
67+
geom_col(width = 0.5, fill = "black") +
68+
coord_cartesian(ylim = c(0.3, 1.7)) +
69+
theme_minimal() +
70+
theme(panel.grid.major.y = element_blank())
71+
72+
ggplotly(p)
73+
```
74+
75+
<div class="plotly html-widget html-fill-item" id="htmlwidget-f58e94ae238d15d3d3d7" style="width:672px;height:480px;"></div>
76+
<script type="application/json" data-for="htmlwidget-f58e94ae238d15d3d3d7">{"x":{"data":[{"orientation":"v","width":100,"base":0.55000000000000004,"x":[50],"y":[0.89999999999999991],"text":"qualitative: 100<br />name: Example","type":"bar","textposition":"none","marker":{"autocolorscale":false,"color":"rgba(190,190,190,1)","line":{"width":1.8897637795275593,"color":"transparent"}},"showlegend":false,"xaxis":"x","yaxis":"y","hoverinfo":"text","frame":null},{"orientation":"v","width":75,"base":0.75,"x":[37.5],"y":[0.5],"text":"quant_value: 75<br />name: Example","type":"bar","textposition":"none","marker":{"autocolorscale":false,"color":"rgba(0,0,0,1)","line":{"width":1.8897637795275593,"color":"transparent"}},"showlegend":false,"xaxis":"x","yaxis":"y","hoverinfo":"text","frame":null}],"layout":{"margin":{"t":26.228310502283104,"r":7.3059360730593621,"b":40.182648401826491,"l":66.484018264840202},"font":{"color":"rgba(0,0,0,1)","family":"","size":14.611872146118724},"xaxis":{"domain":[0,1],"automargin":true,"type":"linear","autorange":false,"range":[-5,105],"tickmode":"array","ticktext":["0","25","50","75","100"],"tickvals":[0,24.999999999999996,50,75,100],"categoryorder":"array","categoryarray":["0","25","50","75","100"],"nticks":null,"ticks":"","tickcolor":null,"ticklen":3.6529680365296811,"tickwidth":0,"showticklabels":true,"tickfont":{"color":"rgba(77,77,77,1)","family":"","size":11.68949771689498},"tickangle":-0,"showline":false,"linecolor":null,"linewidth":0,"showgrid":true,"gridcolor":"rgba(235,235,235,1)","gridwidth":0.66417600664176002,"zeroline":false,"anchor":"y","title":{"text":"quant_value","font":{"color":"rgba(0,0,0,1)","family":"","size":14.611872146118724}},"hoverformat":".2f"},"yaxis":{"domain":[0,1],"automargin":true,"type":"linear","autorange":false,"range":[-0.29999999999999999,2.2999999999999998],"tickmode":"array","ticktext":["Example"],"tickvals":[1],"categoryorder":"array","categoryarray":["Example"],"nticks":null,"ticks":"","tickcolor":null,"ticklen":3.6529680365296811,"tickwidth":0,"showticklabels":true,"tickfont":{"color":"rgba(77,77,77,1)","family":"","size":11.68949771689498},"tickangle":-0,"showline":false,"linecolor":null,"linewidth":0,"showgrid":false,"gridcolor":null,"gridwidth":0,"zeroline":false,"anchor":"x","title":{"text":"name","font":{"color":"rgba(0,0,0,1)","family":"","size":14.611872146118724}},"hoverformat":".2f"},"shapes":[{"type":"rect","fillcolor":null,"line":{"color":null,"width":0,"linetype":[]},"yref":"paper","xref":"paper","x0":0,"x1":1,"y0":0,"y1":1}],"showlegend":false,"legend":{"bgcolor":null,"bordercolor":null,"borderwidth":0,"font":{"color":"rgba(0,0,0,1)","family":"","size":11.68949771689498}},"hovermode":"closest","barmode":"relative"},"config":{"doubleClick":"reset","modeBarButtonsToAdd":["hoverclosest","hovercompare"],"showSendToCloud":false},"source":"A","attrs":{"36486ca2fe7":{"x":{},"y":{},"type":"bar"},"364874f8bdea":{"x":{},"y":{}}},"cur_data":"36486ca2fe7","visdat":{"36486ca2fe7":["function (y) ","x"],"364874f8bdea":["function (y) ","x"]},"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.20000000000000001,"selected":{"opacity":1},"debounce":0},"shinyEvents":["plotly_hover","plotly_click","plotly_selected","plotly_relayout","plotly_brushed","plotly_brushing","plotly_clickannotation","plotly_doubleclick","plotly_deselect","plotly_afterplot","plotly_sunburstclick"],"base_url":"https://plot.ly"},"evals":[],"jsHooks":[]}</script>
77+
78+
79+
80+
### What About Dash?
81+
82+
[Dash for R](https://dashr.plot.ly/) is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library.
83+
84+
Learn about how to install Dash for R at https://dashr.plot.ly/installation.
85+
86+
Everywhere in this page that you see `fig`, you can display the same figure in a Dash for R application by passing it to the `figure` argument of the [`Graph` component](https://dashr.plot.ly/dash-core-components/graph) from the built-in `dashCoreComponents` package like this:
87+
88+
89+
``` r
90+
library(plotly)
91+
92+
fig <- plot_ly()
93+
# fig <- fig %>% add_trace( ... )
94+
# fig <- fig %>% layout( ... )
95+
96+
library(dash)
97+
library(dashCoreComponents)
98+
library(dashHtmlComponents)
99+
100+
app <- Dash$new()
101+
app$layout(
102+
htmlDiv(
103+
list(
104+
dccGraph(figure=fig)
105+
)
106+
)
107+
)
108+
109+
app$run_server(debug=TRUE, dev_tools_hot_reload=FALSE)
110+
```

ggplot2/2021-08-04-choropleth-maps.md

Lines changed: 133 additions & 0 deletions
Large diffs are not rendered by default.

ggplot2/2021-08-04-colorscales.md

Lines changed: 172 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
name: Configuration Options For Embedded Chart Studio Graphs
3+
permalink: ggplot2/configuration-options/
4+
description: How to set configuration options of embedded Chart Studio graphs in ggplot2. Examples of both online and offline configurations.
5+
layout: base
6+
language: ggplot2
7+
thumbnail: thumbnail/modebar-icons.png
8+
display_as: file_settings
9+
order: 9
10+
output:
11+
html_document:
12+
keep_md: true
13+
---
14+
15+
16+
#### Online Configuration Options
17+
18+
Configuration options for graphs created with the `plotly` ggplot2 package are overridden when those graphs are published to Chart Studio using the `api_create()` function.
19+
20+
To set configutation options for charts published to Chart STudio, you can edit the plot's embed url.
21+
22+
Visit our [embed tutorial](http://help.plot.ly/embed-graphs-in-websites/#step-8-customize-the-iframe) for more information on customizing the embed URL to remove the "Edit Chart" link, hide the modebar, or autosize the plot.
23+
24+
#### Offline Configuration Options
25+
26+
Add the 'Edit Chart' link:
27+
28+
``` r
29+
library(plotly)
30+
p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
31+
32+
htmlwidgets::saveWidget(config(p, showLink = T), "graph.html")
33+
```
34+
35+
Remove the 'mode bar':
36+
37+
``` r
38+
htmlwidgets::saveWidget(config(p, displayModeBar = FALSE), "graph.html")
39+
```
40+
41+
#### Reference
42+
Arguments are documented [here](https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js).
43+
### What About Dash?
44+
45+
[Dash for R](https://dashr.plot.ly/) is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library.
46+
47+
Learn about how to install Dash for R at https://dashr.plot.ly/installation.
48+
49+
Everywhere in this page that you see `fig`, you can display the same figure in a Dash for R application by passing it to the `figure` argument of the [`Graph` component](https://dashr.plot.ly/dash-core-components/graph) from the built-in `dashCoreComponents` package like this:
50+
51+
52+
``` r
53+
library(plotly)
54+
55+
fig <- plot_ly()
56+
# fig <- fig %>% add_trace( ... )
57+
# fig <- fig %>% layout( ... )
58+
59+
library(dash)
60+
library(dashCoreComponents)
61+
library(dashHtmlComponents)
62+
63+
app <- Dash$new()
64+
app$layout(
65+
htmlDiv(
66+
list(
67+
dccGraph(figure=fig)
68+
)
69+
)
70+
)
71+
72+
app$run_server(debug=TRUE, dev_tools_hot_reload=FALSE)
73+
```

0 commit comments

Comments
 (0)