Color legend | D3 | Observable
ojs
ojs
ojs
ojs
ojs
ojs
ojs
ojs
ojs
ojs
ojs
ojs
ojs
ojs
ojs
ojs
ojs
Author
Mike Bostock
@mbostock
Visualization toolmaker. Founder
@observablehq
. Creator
@d3
. Former
@nytgraphics
. Pronounced BOSS-tock.
Comments (3)
Andres Snitcofsky
Apr 14, 2021
is there any way to "insert" this type of legend into another svg block ? So to have both the viz and the legend in the same block to be able to "download as png" alltogether?
Mike Bostock
Apr 14, 2021
Yes, legend() returns an SVG element, so you can just append it to another SVG element and set the transform attribute if desired.
quackas
Dec 9, 2021
How would I increase the font size of the labels?
Reply
Add comment
Subscribe to notifications
© 2026 Observable, Inc.
Terms of service
Privacy policy
Product
About
Pricing
Documentation
Release notes
Contact us
Open source
Notebook Kit
Plot
D3
Community
Public
Forum
Bluesky
YouTube
X
Observable
Sign up
D3
Mike Bostock
310
Reply
Add comment
Subscribe to notifications
322
Color legend | D3 | Observable