Move legend position to blank subtitle

I have a figure with 5 subtitles. I declare a subplot (2,3, X), which includes 6 subplots. The 6th subtitle is empty. I am going to move the legend to the 6th empty position for all graphs.

How is this possible?

+6
source share
2 answers

Perhaps try legendflex from File Exchange, it looks like it can do what you want.

+3
source

if you just want to use standard-matlab, you need a subtitle descriptor, and then you need its position. Then you set the legend position to the subtitle position. Referring to the documents:

Note. You can set the location of the legend by passing the 4-element position vector to the legend function using the "Location" option. To determine the position of an existing legend, use the set function to assign a position vector of 4 elements to the Position property. You cannot use the "Location" option with the function installed

eg:

subplot(2,3,1), plot(1:10,2:11) myLegend=legend('text1') set(myLegend,'Units', 'pixels') myOldLegendPos=get(myLegend,'Position') hold on h=subplot(2,3,6) set(h,'Units', 'pixels') myPosition=get(h,'Position') set(myLegend,'Position',[myPosition(1) myPosition(2) myOldLegendPos(3) myOldLegendPos(4)]) 
+4
source

Source: https://habr.com/ru/post/950164/


All Articles