Data cursor with multiple axes

9 views (last 30 days)
Christian
Christian on 18 Jul 2015
Edited: Christian on 18 Jul 2015
My issue surrounds the use of plotyy vs. manually creating multiple axes and the ability to use the data cursor. When I create a two-axis plot with plotyy, I am able to use the data cursor on both axes without any additional commands other than calling plotyy. When I plot to manually-created, overlapping axes on the same figure and then attempt use the data cursor, I am only able to use it on whichever axis is on the top. I can switch between them with uistack, but this is inconvenient.
The only reason I'm trying to avoid plotyy is because of how it behaves when I attempt to format the axes for publication.
Does anyone know how to allow "transparency" of an axis to the one underneath it or how this is implemented in plotyy? I have a feeling a ButtonDwnFcn is being called in the top axis when it's created with plotyy.
Below I have excerpts of the plotting portion of my scripts:
With plotyy:
figure;
[hax_yy,htmp_abs,htmp_em] = plotyy([0 0],[1 1],[0 0],[1 1]); % Create dummy plots
h_uv = copyobj(h_uv,hax_yy(1)); % Copy handles from previously plotted data
h_em = copyobj(h_em,hax_yy(2));
delete(htmp_abs,htmp_em); % Delete dummy plots
With manual axes:
figure;
new_hax_abs = axes; % Make left-hand axes
h_uv = copyobj(h_uv,new_hax_abs); % Copy data
ax_minwl = min(get(hax_abs,'xlim'));
ax_maxwl = max(get(hax_em,'xlim'));
set(new_hax_abs,'xlim',[ax_minwl ax_maxwl]); % Set x limits to full range of both plots
set(new_hax_abs,...
'Units','normalized',...
'FontUnits','points',...
'FontWeight','normal') % LH axes properties
axesPosition = get(gca,'Position');
new_hax_em = axes('Position',axesPosition,...
'Color','none',...
'YAxisLocation','right',...
'XTick',[],...
'Box','off'); % Right-hand axes
linkaxes([new_hax_abs new_hax_em],'x');
h_em = copyobj(h_em,new_hax_em);

Answers (0)

Categories

Find more on Two y-axis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!