-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddRPlot.m
executable file
·36 lines (32 loc) · 1 KB
/
AddRPlot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function [rax,h] = AddRPlot(lax, varargin)
%[rax,h] = AddRPlot(lax, varargin)
% add an additional axis on the RHS of a graph which already has an axis (lax) on
% the left
if isfigure(lax)
fig = lax;
axs = findobj(allchild(fig),'flat','type','axes');
lax = axs(1);
else
fig = get(lax,'Parent');
axs = findobj(allchild(fig),'flat','type','axes');
end
set(lax,'Box','off');
ax1hv = get(lax,'HandleVisibility');
rax = [];
for j = 1:length(axs)
p = get(axs(j),'YaxisLocation');
if strcmp(p,'Right')
rax = axs(j);
end
end
if isempty(rax) || force
rax = axes('HandleVisibility',ax1hv,'Units',get(lax,'Units'), ...
'Position',get(lax,'Position'),'Parent',fig);
end
%%raxis = axes('Position',get(gca,'Position'),'color','None');
if nargin > 1
h = plot(varargin{:});
end
set(rax,'YAxisLocation','right','Color','none', ....
'XGrid','off','YGrid','off','Box','off','XtickLabel',[],...
'Xlim',get(lax,'Xlim'),'Xscale',get(lax,'Xscale'));