8

According to the documentation

BarLegend is displayed in StandardForm as a graphics object

and it do looks like a normal graphics in front end.

However,

BarLegend["Rainbow"]//FullForm

still gives BarLegend["Rainbow"]

and

Show[BarLegend["Rainbow"]]

will give errors

Show::gtype: BarLegend is not a type of graphics.

So is there a way to convert legends to graphics objects?

matheorem
  • 17,132
  • 8
  • 45
  • 115

2 Answers2

8
First @ Cases[
  ToBoxes @ BarLegend["Rainbow"],
  gr_GraphicsBox :> ToExpression[gr],
  ∞
]
Kuba
  • 136,707
  • 13
  • 279
  • 740
2

Also

ToExpression[MakeBoxes[BarLegend["Rainbow"]][[1,1]]][[1]]
kglr
  • 394,356
  • 18
  • 477
  • 896