New answers tagged

2

Here's a functional solution to make a general 2-scale legend. Options[twoScaleLegend] = {"LegendOrientation" -> "Horizontal"}; twoScaleLegend[{xmin_, xmax_}, {label1_, label2_}, scale2_, opts : OptionsPattern[{twoScaleLegend, DensityPlot}]] := Module[{ticks, aspectratio, framelabel, ticklength}, ticklength = ...


2

I found a solution that is not general but working for me at the moment. Since I was looking for a simple linear scaling I just applied it to the range argument 1.8*{1, 100} + 32 in BarLegend Legended[ MatrixPlot[Table[i*j, {i, 1, 10}, {j, 1, 10}], ColorFunction -> (ColorData["SolarColors"][Rescale[#, {1, 100}]] &), ColorFunctionScaling ...


3

To my mind there are four ways of making the array plot with the BrownCyanTones gradient and a bar legend that seem reasonable. Data range -1 to 1, plot range -1 to 1, lengend range -1 to 1 SeedRandom[1]; ArrayPlot[RandomReal[{-1, 1}, {10, 10}], ColorFunction -> "BrownCyanTones", PlotLegends -> BarLegend[{"BrownCyanTones", {-1, 1}}]] Data ...


3

You are using it wrong. The default algorithm for PlotLegends will supply the correct ColorFunction to BarLegend, so use ArrayPlot[RandomReal[{-1, 1}, {10, 10}], PlotLegends -> Automatic, ColorFunction -> ColorData[{"BrownCyanTones", {-5, 1}}], PlotRange -> {-5, 1}, ColorFunctionScaling -> False] If you need to modify the legend, ...


3

Can confirm this happens in 10.3 Win 7 Pro 64 bit. You can get around it with Legended. Legended[ ArrayPlot[RandomReal[{-1, 1}, {10, 10}], ColorFunction -> ColorData[{"BrownCyanTones", {-5, 1}}], PlotRange -> {-5, 1}, ColorFunctionScaling -> False], BarLegend[{"BrownCyanTones", {-5, 1}}]] Hope this helps.


3

The answer to your question is, it depends. If the legend is placed inside the area of the graphic, then the graphic, including the legend, can be highlighted and saved by right-clicking and choosing Save Graphics As... The code used to produce this graphic is Plot[{Sin[x], Cos[x]}, {x, 0, 2 π}, PlotStyle -> {Black, Red}, PlotLegends -> ...


2

I always had problems with that. I use Export and the expression in order to get the legend in the exported figure. plot = Show[ Plot[Sin[x], {x, 0, 2 π}, PlotStyle -> Black, PlotLegends -> LineLegend[{Black}, {"Sin"}]], Plot[Cos[x], {x, 0, 2 π}, PlotStyle -> Red, PlotLegends -> LineLegend[{Red}, {"Cos"}]], BaseStyle -> ...


1

Legends are heavily affecting the performance in Dynamic so I'd probably go with some hand made legends anyway: Manipulate[ Grid[{{ Dynamic @ Plot[{a Sin[x], a Cos[x]}, {x, 0, 2 Pi}] , LineLegend[ {RGBColor[0.368417, 0.506779, 0.709798], RGBColor[0.880722, 0.611041, 0.142051]}, TraditionalForm /@ {Dynamic[a Defer@Sin[x]], Dynamic[a ...


3

The FrontEnd has the habit of renaming variables, which is usually a good thing, but sometimes can be troublesome. One possibility is to evaluate the argument of Plot, e.g.: Manipulate[ NumberForm[ Plot @@ {{a Sin[x], a Cos[x]}, {x, 0, 2 Pi}, PlotLegends -> "Expressions", PlotRange -> {-2, ...



Top 50 recent answers are included