Tag Info

Hot answers tagged

7

Using either Swatchlegend, PointLegend, LineLegend, Barlegend you can easily generate a legend like you would get in a plot. SwatchLegend[{Red, Green, Blue}, {"red", "green", "blue"}] PointLegend[{Red, Green, Blue}, {"red", "green", "blue"}] LineLegend[{Red, Green, Blue}, {"red", "green", "blue"}] BarLegend["Rainbow"] Non-default styles are ...


6

Update: Generate a separate legend with the default color scheme and export it: lineleg = LineLegend["DefaultPlotStyle"/. (Method/. Charting`ResolvePlotTheme[Automatic, ListLinePlot]), {"leg1", "leg2", "leg3"}]; Export["plotlegend.pdf",lineleg] To get the default colors associated with various PlotThemes you can use the function ...


5

Legended[ContourPlot[x y, {x, 0, 1}, {y, 0, 1}], Placed[BarLegend[{ColorData["M10DefaultDensityGradient"], {0, 1}}, LegendLayout -> "Row"], Below]] I found the name of the color scheme by evaluating plot = ContourPlot[x y, {x, 0, 1}, {y, 0, 1}, PlotLegends -> Automatic] and looking at the expression of the result. As Legended accepts two ...


3

This happens because legend items are wrapped in HoldForm to prevent the elements from taking on values: Observe: c = 5; RegionPlot[{x^2 + y^2 <= c, x < 0}, {x, -Pi, Pi}, {y, -Pi, Pi}, PlotLegends -> "Expressions"][[2, 1, 2]] // InputForm {HoldForm[x^2 + y^2 <= c], HoldForm[x < 0]} Without the HoldForm any global values (such as c ...


2

My main suggestion would be to use existing legending functionality in version 9+, e.g. LineLegend rather than hack things together from scratch like this. I think the main issue with your code and the reason it does not work, is that you are not actually providing any means for text-formatting options to affect your labels. The relevant piece of code in ...



Only top voted, non community-wiki answers of a minimum length are eligible