Move legend to middle of figure
    54 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I am try to stacked plots of bar graphs for a scientific publication. When trying to the position of the legend, it does not fit well inside the figure area on either side and I would rather put it on the outside of the figure area to save on space. Is it possible to manually set the position of the legend in the plot area and move it into the middle where it would fit nicely. The sample code (top plot) I have for the legend so far is:
plotleg = legend('\DeltaTA','TA^{DIC-TA}_{calc}','Salinity','Location','northwest','Orientation','horizontal');
legend('boxoff');
set(plotleg,'FontSize',11);
Figure below.
0 Commenti
Risposte (3)
  Pritesh Shah
      
 il 15 Ott 2016
        In figure editor, you can move legend. (Edit-> Figure properties -> click on legend)
0 Commenti
  Image Analyst
      
      
 il 15 Ott 2016
        
      Modificato: Image Analyst
      
      
 il 13 Mar 2022
  
      You can use an "outside" location option, for example
data = rand(5, 4); % Each column is one set of data (one color below in the plot).
bar(data);
grid on;
legend('Location', 'eastoutside')
title('My Title')
If you use 'northoutside', the legend bars will be stacked vertically, not horizontally like you want.
data = rand(5, 4);
bar(data);
grid on;
legend('Location', 'northoutside')
title('My Title')
See the help for all the location options.  
If you use the interactive toolbar on the figure (the last icon on the right on the toolbar) to set the properties, you can click on the legend box, and move it to wherever you want it, inside or outside.
0 Commenti
  Clinnt Lunna
 il 11 Mar 2022
        You can just write 'north' for the location part if you want it at top center.
0 Commenti
Vedere anche
Categorie
				Scopri di più su Legend in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

