New answers tagged

5

Actually the answer is already given in the documentation for SwatchLegend. All you need to do is to wrap Legended around the Show: Legended[ Show[ plot1, plot2, PlotRange -> All ], SwatchLegend[ {Red, Yellow}, {"A", "B"} ] ] Note: Should the legend become larger and is entered by hand, using Transpose may make this easier, e.g. SwatchLegend @@ ...


2

I would suggest creating the legend separately and combine with Grid. Grid[{{Show[plot1, plot2, PlotRange -> All], SwatchLegend[{Red, Yellow}, {"plot1", "plot2"}]}}]


1

Example Code ListPlot[{a, b}, Joined -> True, PlotStyle -> {Red, Yellow}, PlotLegends -> Automatic] Note: a and b are your original data lists a1 and a2 respectively. Output With SwatchLegend Code ListPlot[ {a, b}, Joined -> True, PlotStyle -> {Red, Yellow}, PlotLegends -> SwatchLegend[{"a", "b"}] ] Output With Show Code ...


2

Use Show instead of Epilog to add on the rectangles, and the legend will stay on top. Show[ ListDensityPlot[..., PlotLegends -> ...] Graphics[{...}] ]


1

To format the plot legend you will have to go beyond PlotLegends -> Automatic. Here is an example of a formatted plot legend. VectorDensityPlot[{x, -y}, {x, -5, 5}, {y, -5, 5}, PlotLegends -> BarLegend[Automatic, LegendLabel -> "Cooper Std", LabelStyle -> {Bold, 16, FontFamily -> "Cooper Std"}]]


2

Thank you for your post, but I now plot the Legend with a Contourplot and get the full control over all options: plotoptions = {ColorFunction -> (ColorData["Rainbow"][ Rescale[#, {0, .125}]] &), MeshFunctions -> Table[#3 &, {i, 1, Length[{0, .025, .05, .075, .1, .125}]}], Mesh -> Table[{{tick, Lighter[White, ...


7

This looks like a bug. Please report it to Wolfram Support. A simple workaround is to specify your own colour function. ArrayPlot[{{1, 0.1, 0}, {0.1, 0, 0}}, PlotLegends -> Automatic, ColorFunction -> (GrayLevel[1 - #] &)]


6

incRange = 0.020; maxRange = 0.120; BarLegend[{"Rainbow", {0, maxRange}}, Ticks -> Table[i, {i, incRange, maxRange - incRange, incRange}], TickLengths -> 25, RotateTicks -> 180, TicksStyle -> Directive[Opacity[1], White, Dashed, FontColor -> Black], LabelStyle -> {FontSize -> 12}, LegendMarkerSize -> {20, 300}]


1

Maybe this is helpful: myR = Range[10, 80, 10]; lp1 = ListPlot[Sqrt[Range[myR[[1]]]], PlotStyle -> Red, PlotMarkers -> "☐"]; lp2 = ListPlot[Sqrt[Range[myR[[2]]]], PlotStyle -> Blue, PlotMarkers -> "⦿"]; lp3 = ListPlot[Sqrt[Range[myR[[3]]]], PlotStyle -> Blue, PlotMarkers -> "⦿"]; lp4 = ListPlot[Sqrt[Range[myR[[4]]]], PlotStyle -> ...


4

You can use Legended (look at documentation to customize for your needs). Dummy data for illustrative purposes: Legended[Grid[ Partition[ Plot[{##}, {x, -1, 1}, PlotStyle -> {Red, Blue}] & /@ {{1 - x, x^2}, {2 - x, x^2 - 1}, {x, 1 - x^2}, {x + 1, 2 - x^2}}, 2]], LineLegend[{Red, Blue}, {"Condition 1", "Condition 2"}]]


4

Starting with the Szabolcs' Notebook from the comment, it is as simple as follows using Mathematica 10: << PolygonPlotMarkers` fm[name_, size_: 7] := Graphics[{EdgeForm[], PolygonMarker[name, Offset[size]]}] ListPlot[ Table[Accumulate@RandomReal[1, 10] + i, {i, 3}], PlotMarkers -> fm /@ {"Triangle", "Square", "Diamond"}, Joined -> True, ...


5

I don't know about PolygonPlotMarkers` package, so I am presenting a general solution. You can always define your own Graphics as markers. For example, I use here regular polygons col = {Red, Blue, Green, Orange, Black}; marker[col_, n_] := Graphics[{col, Polygon[{Cos[2 Pi #/n], Sin[2 Pi #/n]} & /@ Range[n]]} ,...



Top 50 recent answers are included