MATLAB: Moving label for secondary axis

move second axis labelplotyy

Hi,
I'm shocked by how unobvious this is, so sorry for asking. I created a multiple plot figure with double axis, and all share the same label for it, as you can see in the figure. I'd like to move the label for that axis to make it more centered. Is there a way to control that from the editor? I dived into the plot browser, but I can only modify the tick labels, not the axis label. Any ideas?
Thank you in advance!!

Best Answer

The axis labels are centered on the axis to which they're attached. It appears you used the third (2nd from bottom) subplot to attach the label to.
You can move the label via the editor manually, but programmatically, it's possible by changing the 'position' property of the label. The second value of the three-vector is the vertical location for the center of the label computed to center it on that axes in units of data coordinates. This is quite inconvenient for multiple plots where the data values aren't the same and there are multiple axes. The best idea I've got programmatically would be to
  1. retrieve the axes positions for the bottom and top axes;
  2. compute the vertical extent of these and then
  3. write the label using that position with normalized coordinates
...[former manner elided for brevity...the following is much better]...
The only other solution that eases some of those problems but has other complexities is that one could create another axes of the same extent vertically as the range of the bottom and top subplots but laying to the right of the RH axes. There's an example in the documentation that overlays another axes in the middle of a 2x2 grid that outlines the basic procedure. In this case, with that axes of that overall height, the ylabel would automagically be centered vertically.
There's a File Exchange submission for super titles that addresses the issue for titles not being associated with each axes but overall; whether somebody may have submitted similar for legends or not I don't know; undoubtedly worth a search to see what could find.
ADDENDUM
As noted, had a few minutes and looked at the added-axes option a little more in depth...
for i=1:4,hA(i)=subplot(4,1,i);end
pos1=get(hA(1),'position'); % extents of top axes
pos4=get(hA(4),'position'); % and bottom
pos=[pos4(1:3) pos1(2)+pos1(4)-pos4(2)]; % overall extent of all axes
hAOuter=axes('position',pos,'visible','off'); % invisible one overlaying those
hL=ylabel(hAOuter,'Charcoal index','fontsize',12,'visible','on');
NB: 'visible','on' in the ylabel properties; it'll be 'off' by default as its value is inherited from the parent axes that we made invisible.