Borrar filtros
Borrar filtros

How to define the parent axes for a legend object?

9 visualizaciones (últimos 30 días)
Tolga Karabiyikoglu
Tolga Karabiyikoglu el 5 de Sept. de 2019
Comentada: Tolga Karabiyikoglu el 5 de Sept. de 2019
Hi there everyone. My trouble is a bit nerve cracking but I've been striding for a couple of hours with no solution.
Say, I've got a full screen sized figure object with a panel on the right inside of the figure frame and two axes on the left. One of the axes has 32 semi logarithmic plots within which only 5 of those plots needs to be defined in a corresponding legend box. Each of the 32 plots are defined with indexed parents and the ones to be legended have display names defined.
Yet the trouble is, when it comes to define the axes of the object to include the legend, it falters. Yes, I did try
"legend(hgrph(1:5),'Location','best');" or
"lgnd1=legend(hAx(1),hgrph(1:5),'Location','best');" or
"lgnd1=legend(hgrph(1:5),'Location','best',hAx(1));" or
"lgnd1=legend(hgrph(1:5),'Location','best');
lgnd1.Parent=hAx(1);" sequence.
commands, but none did work. Obviously 'hAx(1)' refers to the handle of the axes I want to legend and 'hgrph(1:5)' are the handles of the semilogx plots to be legended.
All of the hgrph(1:5) handled plots have their display names defined via the corresponding semilogx commands. Remember I've said I got 32 plots parented the same axes and I just need five of them to be legended.
Best wishes to save me out of this,
  5 comentarios
Adam
Adam el 5 de Sept. de 2019
Yes, I was originally considering suggesting that there is a setting you can apply to each individual plot that tells a legend whether or not to include it, but the ability to select subsets for legends (which I think is relatively new) seemed to render this rather an over the top way of doing it.
Good that you found a way that works though.
Tolga Karabiyikoglu
Tolga Karabiyikoglu el 5 de Sept. de 2019
Considering my final solution was on Matlab 2018b....

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by