Skip to content

Commit f4737c0

Browse files
author
mahdis-z
committed
insidetextorientation examples
1 parent 51f28e4 commit f4737c0

4 files changed

+39
-6
lines changed

r/2015-11-19-pie-charts.Rmd

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@ fig
104104

105105
See more examples of subplots [here](https://plot.ly/r/subplots/).
106106

107+
#### Controlling text orientation inside sunburst sectors
108+
109+
The `insidetextorientation` attribute controls the orientation of text inside sectors. With "auto" the texts may automatically be rotated to fit with the maximum size inside the slice. Using "horizontal" (resp. "radial", "tangential") forces text to be horizontal (resp. radial or tangential). Note that `plotly` may reduce the font size in order to fit the text with the requested orientation.
110+
111+
```{r}
112+
library(plotly)
113+
114+
labels = c('Oxygen','Hydrogen','Carbon_Dioxide','Nitrogen')
115+
values = c(4500, 2500, 1053, 500)
116+
117+
fig <- plot_ly(type='pie', labels=labels, values=values,
118+
textinfo='label+percent',
119+
insidetextorientation='radial')
120+
fig
121+
```
107122
### Donut Chart
108123

109124
```{r}

r/2017-05-28-cumulative-animations.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ accumulate_by <- function(dat, var) {
3434
dplyr::bind_rows(dats)
3535
}
3636
37-
d <- txhousing
38-
fig <- d %>%
37+
df <- txhousing
38+
fig <- df %>%
3939
filter(year > 2005, city %in% c("Abilene", "Bay Area"))
4040
fig <- fig %>% accumulate_by(~date)
4141

r/2018-01-29-hover-text-and-formatting.Rmd

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,9 @@ fig
116116
```{r}
117117
library(plotly)
118118
119-
d <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/job-automation-probability.csv')
119+
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/job-automation-probability.csv')
120120
121-
fig <- d
122-
123-
fig <- fig %>%
121+
fig <- df %>%
124122
plot_ly(
125123
type = 'scatter',
126124
mode = 'markers',

r/2019-04-12-sunburst-chart.Rmd

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,26 @@ d <- data.frame(
8585
8686
fig <- plot_ly(d, ids = ~ids, labels = ~labels, parents = ~parents, type = 'sunburst')
8787
88+
fig
89+
```
90+
#### Controlling text orientation inside sunburst sectors
91+
92+
The `insidetextorientation` attribute controls the orientation of text inside sectors. With "auto" the texts may automatically be rotated to fit with the maximum size inside the slice. Using "horizontal" (resp. "radial", "tangential") forces text to be horizontal (resp. radial or tangential). Note that `plotly` may reduce the font size in order to fit the text with the requested orientation.
93+
94+
```{r}
95+
df = read.csv('https://raw.githubusercontent.com/plotly/datasets/718417069ead87650b90472464c7565dc8c2cb1c/coffee-flavors.csv')
96+
97+
fig <- plot_ly()
98+
99+
fig <- fig %>% add_trace(
100+
type='sunburst',
101+
ids=df$ids,
102+
labels=df$labels,
103+
parents=df$parents,
104+
domain=list(column=1),
105+
maxdepth=2,
106+
insidetextorientation='radial'
107+
)
88108
fig
89109
```
90110

0 commit comments

Comments
 (0)