Tag Info

Hot answers tagged

7

points = Table[{x, .5 x^2 - 3 + RandomReal[]}, {x, -3, 3}]; Show[{ListPlot[points, PlotLegends -> {"Experiment"}], Plot[{.5 x^2 - 3}, {x, -3, 3}, PlotStyle -> Red, PlotLegends -> {"Model"}]}]


5

You can use the (afaik undocumented) option "Ticks" ContourPlot[Sin[x] Cos[y], {x, 0, 2 Pi}, {y, 0, 2 Pi}, Contours -> {Automatic, 10}, ColorFunction -> "Rainbow", PlotLegends -> BarLegend[Automatic, None, "Ticks" -> {{-1, "cold"}, {0, "ok"}, {1, "hot"}}]] Note: You can also use Ticks instead of "Ticks" and ignore the red highlighting ...


4

This points out that Legended is typeset instead of being evaluated in the kernel evaluation time. The evidence is in that InputForm[p] still contains two Legendeds and the graphics only one. This is what you need: Show[ListPlot[Range[10], PlotLegends -> {"a"}, PlotStyle -> Red], ListPlot[Range[10] + 2, PlotLegends -> {"b"}, PlotStyle -> ...


2

You can also use "FrameStyle"->Thick in Version 10: ContourPlot[y - x^2, {x, 0, 1}, {y, 0, 1}, ContourStyle -> Directive[Thick, Black, Opacity[1]], FrameStyle -> Thick, PlotLegends -> BarLegend[Automatic, "FrameStyle" -> Thick]] In Version 9 (Windows 8 x64) BarLegend[Automatic, "FrameStyle" -> Thick] renders only three sides of the ...


2

You can use BinCounts for that purpose, e.g. in that fashion: Block[{bw = {0, 50, 2}, ds1 = #"Var1" & /@ Normal[ds[Select[#"Var2" == 1 &]]], ds2 = #"Var1" & /@ Normal[ds[Select[#"Var2" == 2 &]]], ds3 = #"Var1" & /@ Normal[ds[Select[#"Var2" == Null &]]], bc1, bc2, bc3}, {bc1, bc2, bc3} = (ToString@Total@BinCounts[#, bw]) ...


2

I think it is PlotLegend instead of PlotLegends (This is on Windows 7 in Mathematica 10.0.2 X64)


1

You are using Mathematica 10. Generally speaking you should abandon the old PlotLegends package and use the newer, better legending functions. For your example: B[Q_, K_] := Cos[π/(⌊Q/K⌋ + 2)]; q = 3; Plot[{B[q, k], 0.75, 0.90}, {k, 1, 6}, PlotLegends -> LineLegend["Expressions", LabelStyle -> {FontFamily -> "Times", Italic, 18}, ...


1

ListLinePlot[Legended[#, Style[#2, Bold, 15]] & @@@ Transpose[{activity, label}], Axes -> False, FrameTicks -> tickSpecs, Frame -> {True, True, False, False}, FrameStyle -> Directive[FontSize -> 20, FontWeight -> Bold], PlotStyle -> (Thread[{Darker /@ colors, Dashing[{0.05}], Thick}]), PlotMarkers -> ...


1

I'm not exactly sure what you want but here's the solution to a possible interpretation. Here are some test data ds = RandomVariate[NormalDistribution[1, 1], {10^4}]; The histogram of which is h = Histogram[ds]; (* output not shown here *) Now there's a function HistogramList[] which gives hlst = HistogramList[ds] (* Out[324]= {{-(13/5), -(12/5), ...


1

There may be cases where Show[] is preferred (e.g. when combining ListPlot and Plot). In that case nesting the Show function was found to preserve the order of the legend items. In the above example, the following was found to preserve the legend order. Show[Plots[[1]]]; Show[%, Plots[[2]]]; Show[%, Plots[[3]]]; Show[%, Plots[[4]]]; Show[%, Plots[[5]]]; ...


1

Legended[Show[ListLinePlot[{1, 2, 3}, PlotStyle->Red], Plot[x^2, {x, 1, 3}, PlotStyle->Blue]], Placed[LineLegend[{Red, Blue}, {"graph1", "graph2"}], {0.8, 0.5}]]



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