MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by Matt J
on 19 Oct 2012

When I add a line object to my plot, the legend is for some reason pushed into the background behind the plot axis, where it is hidden. Why does this happen and how do I bring it into the foreground again?

*No products are associated with this question.*

Answer by Matt Fig
on 19 Oct 2012

Edited by Matt Fig
on 19 Oct 2012

Accepted answer

I cannot reproduce this with:

plot(1:10) legend('plot') line([5 5],[0 10])

So I want to ask what your code looks like. If you only have the one plot axes and the legend (no uicontrols or other figure children), then this will bring the legend back:

set(gcf,'children',flipud(get(gcf,'children')))

If you have other figure children, the idea is the same, you will just have to be more careful about the rearrangement.

## 1 Comment

## Azzi Abdelmalek

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/51339#comment_106167

Can you post your code?