Skip to content

Commit 8bc3ff8

Browse files
author
mahdis-z
committed
legend item's size
1 parent dd476b2 commit 8bc3ff8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

r/2015-07-30-legend.Rmd

Lines changed: 25 additions & 0 deletions
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 [itemsizing](https://plot.ly/r/reference/#layout-legend-itemsizing) attribute determines the legend items symbols remain constant, regardless of how tiny/huge the bubbles would be 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

0 commit comments

Comments
 (0)