I am currently struggling with a problem which I haven't seen answered anywhere else.
I want to make a ListDensityPlot
graph in which I need to draw some rectangles above the graph (I used Epilog
, no problem here), but I also want to place the legend over that Epilog. However, when I do it (using Placed
), the legend lays behind the Epilog, and thus is invisible...
Is there any way I can solve this?
If you need any other details, I can provide them.
Thanks in advance!
EDIT: what I want is something like this:
f[x_, y_] := x^2 + y^2
fTab = Flatten[Table[{x, y, f[x, y]}, {x, -1, 1, 0.1}, {y, -1, 1, 0.1}], 1];
Rec = Epilog -> {Directive[LightGray],Rectangle[{-1, -0}, {-0.5, -1}],Rectangle[{-0.5, -1}, {0.5, -0.5}],Rectangle[{1, 0}, {0.5, -1}]};
Leg = PlotLegends -> Placed[BarLegend[{"Rainbow", {-1, 1}}, LegendLayout -> "ReversedRow", LegendMarkerSize -> 200, LegendLabel -> Placed["f(x,y)", Left], LabelStyle -> Directive[FontSize -> 15]], {0.5, 0.1}]
ListDensityPlot[fTab, ColorFunction -> "Rainbow", Evaluate[Rec], Evaluate[Leg]]
Labeled
$\endgroup$ListDensityPlot
that's it? $\endgroup$