# When a 2D plot is used as an Epilog to the MatrixPlot, the frame disappears. Any workarounds? [duplicate]

So, I faced this problem, which is probably because of the bug.

Let's plot a simple 2D graph.

sample2dPlot =
ListPlot[RandomReal[{-1, 1}, 100], Background -> White,
Frame -> True, FrameLabel -> {"x", "y"}]


Let's try to use it as the Epilog to the MatrixPlot

MatrixPlot[RandomReal[{-1, 1}, {100, 100}], PlotLegends -> Automatic,
Epilog -> Inset[sample2dPlot]]


The frame disappeared, the frame labels disappeared.

Does anybody know how to solve this problem?

Thank you.

• Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– user9660
Nov 11, 2016 at 7:43
• Can confirm this as a bug, going back at least to version 8. Nov 11, 2016 at 15:03
• This question is a duplicate of (103192). In particular, the patch given by Mr. Wizard in his answer can be applied here.
– user31159
Nov 11, 2016 at 15:13

Update:

Here's another workaround, based on the same underlying idea as the original:

MatrixPlot[RandomReal[{-1, 1}, {100, 100}], PlotLegends -> Automatic,
Epilog -> "foo"] /. "foo" -> Inset[sample2dPlot]


MatrixPlot[RandomReal[{-1, 1}, {100, 100}], PlotLegends -> Automatic,

(The underlying idea was to keep MatrixPlot from messing the options, assuming it does. In any case it works on the OP's example, if you have dynamic updating enabled. I find the dependence on Dynamic less satisfactory for this reason.)