Tag Info

New answers tagged

0

I voted to close this as a duplicate but since the OP said "it seems too complicated for what I needed to do" here is a way to do it. Copy the whole code given by Jens and modify the function legendMaker by commenting Line[...] in f: If[#1 === {None} || (PlotStyle /. {opts}) === None, {}, Line[{{-.1,0}, {.1,0}}]] should be: If[#1 === {None} || ...


1

The code from the previous question's answer seems to work just as well here with the use of SwatchLegend: Legended[GraphicsGrid[{{Graphics[box1], Graphics[box2]}}], Placed[SwatchLegend[56, {"A", "B"}, LegendLayout -> "Row"], Above]]


0

LegendLayout -> {"Column",2} does exactly what you wanted. Plot[{(1 - bet) 1/(2 Sqrt[bet]), Sqrt[bet], bet^(1/4), (1 - bet) 1/(4 bet^(3/4))}, {bet, 0, 1}, PlotLegends -> Placed[LineLegend[{"MR1", "MC1", "MR2", "MC2"}, LegendLayout -> {"Column", 2}], Below], AxesLabel -> {"\[Beta]", "MR,MC"}, Ticks -> {Automatic, None}]


3

To me it looks like there is a bug in the Implementation of BarLegend. When the the number of contours increases there is not only a switch from discrete contours to a continuous gradient (this behavior is documented), but also a change in the scaling (that's the bug). colorf = Blend[{{0, Red}, {20, Yellow}, {40, Green}}, Round[#, 0.1]] &; ...


2

Blend was modified in version 10. It appears that Blend is now scaled to {0, 1}. colorf = Blend[{{0, Red}, {0.5, Yellow}, {1, Green}}, Round[#, 0.01]] &; BarLegend[{colorf, {0, 30}}]


0

I believe this one is simple enough: Plot[{bet, bet^2, bet^3, bet^4}, {bet, 0, 1}, PlotLegends -> Placed[{"MR1", "MC1", "MR2", "MC2"}, Below]] /. "Row" :> (Grid[Apply[Sequence, Partition[#, 2], {2}]] &) Edit: Here you can see how you can reorder the legends easily Plot[{bet, bet^2, bet^3, bet^4}, {bet, 0, 1}, PlotLegends -> ...


0

Plot[{(1 - bet) 1/(2 Sqrt[bet]), Sqrt[bet], bet^(1/4), (1 - bet) 1/(4 bet^(3/4))}, {bet, 0, 1}, PlotLegends -> Placed[LineLegend[ ColorData[97, "ColorList"][[{1, 2, 3, 4}]], {"MR1 lorem ipsum", "MC1 lorem ipsum", "MR2 lorem ipsum", "MC2 lorem ipsum"}[[{1, 2, 3, 4}]], LegendLayout -> (Grid@Transpose@Partition[Row /@ #, 2] ...


1

This is not another answer but rather an extension of kguler's correct response. Further issues are also identified. In order to help use kguler's answer I have made a function which may be useful to others. ClearAll[plotColors]; plotColors::usage = "plotColors[plotType,plotTheme] gives a list of the colors used in \ a plot when several curves are ...


4

Use colors=(("DefaultPlotStyle"/.(Method /. Charting`ResolvePlotTheme["Scientific" , ListLinePlot]))/. Directive[x_,__]:>x) to get the colors used in the "Scientific" plot theme. Then use colors as the first argument of LineLegend: Column[{ Row[{Style["Data from experiment 5B", FontFamily -> "Times", FontSize -> 12]}, Alignment -> ...


1

MatrixPlot[RandomReal[{1, 4}, {10, 10}], PlotLegends -> BarLegend[{ColorData[{"Temperature", {1, 4}}], {1, 4}}], ColorFunction -> (ColorData[{"Temperature", {1, 4}}]), ColorFunctionScaling -> False, DataReversed -> True] Version 9.0.1.0: Version 10.0.1.0 (Wolfram Programming Cloud): Update: PlotLegends -> ...


3

There's an example exactly like this in the documentation for BoxWhiskerChart. All you need to do is reshape your data into a list of doubles: xdata = {{"A", {1, 2, 5}}, {"B", {5, 7, 2, 2, 5}}, {"C", {3, 2, 5, 7}}}; ydata = {{"A", {7, 2}}, {"B", {7, 2, 5}}, {"C", {6, 7, 3}}}; labels = {xdata[[All, 1]], None} xdata = xdata[[All, 2]]; ydata = ydata[[All, ...


10

You have to add the index for the colors to LineLegend Legended[Grid[{{Show[oniplot], Show[cpplot]}}], LineLegend[97, {"factor = 2", "factor = 3", "factor = 4", "factor = 5"}]] In order to have the legend above the plots and with markers: Legended[GraphicsGrid[{{oniplot, cpplot}}], Placed[LineLegend[97, Array["factor = " <> ToString@# ...


3

Your second solution can be improved by Evaluate[] on the first plot argument. Plot[Evaluate[y /. sol], {x, -10, 10}, PlotLegends -> Automatic]


6

f@x_ := ColorData["VisibleSpectrum"][Rescale[x, {0, 1}, {380, 750}]]; Plot3D[ Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> f, PlotLegends -> BarLegend[{f@# &, {0, 1}}]]



Top 50 recent answers are included