8000 Merge pull request #36 from plotly/itemsizing · plotly/plotly.r-docs@8002285 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8002285

Browse files
authored
Merge pull request #36 from plotly/itemsizing
legend item's size
2 parents 2debb5b + d7bd275 commit 8002285

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

r/2015-07-30-legend.Rmd

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,31 @@ fig <- fig %>% add_trace(y = ~Tree4, name = 'Tree 4')
162162
fig <- fig %>% add_trace(y = ~Tree5, name = 'Tree 5')
163163
fig <- fig %>% layout(legend = l)
164164
165+
fig
166+
```
167+
168+
### Size of Legend Items
169+
170+
In this example, since the [itemsizing](https://plot.ly/r/reference/#layout-legend-itemsizing) attribute is set to `constant`, the size of legend items symbols remains the same, regardless of how tiny/huge the bubbles are in the graph.
171+
172+
```{r}
173+
library(plotly)
174+
175+
fig <- plot_ly(
176+
type='scatter',
177+
x=c(1, 2, 3, 4, 5),
178+
y=c(1, 2, 3, 4, 5),
179+
mode='markers',
180+
marker=list(size=10))
181+
182+
fig <- fig %>% add_trace(
183+
type='scatter',
184+
x=c(1, 2, 3, 4, 5),
185+
y=c(5, 4, 3, 2, 1),
186+
mode='markers',
187+
marker=list(size=100))
188+
189+
fig <- fig %>% layout(legend= list(itemsizing='constant'))
165190
fig
166191
```
167192
### Legend Title
@@ -260,4 +285,4 @@ fig
260285

261286
Reference
262287

263-
See [https://plot.ly/r/reference/#layout-legend](https://plot.ly/r/reference/#layout-legend) for more information and chart attribute options!
288+
See [https://plot.ly/r/reference/#layout-legend](https://plot.ly/r/reference/#layout-legend) for more information and chart attribute options!

0 commit comments

Comments
 (0)
0