GUI reset secondary axes that contain no data

1 view (last 30 days)
Hi, I've got an Arrhenius diagram that describes diffusion (x: 10000 / T ; y: log(D)) embedded in a GUI for which I generate secondary axes showing the corresponding temperature at the top of the diagram. But I do not use the secondary axis to plot data. The plot is generated via a push-button. Each time I press this button, the secondary axes gets plotted again and thus the axes and labels get thicker with each click. I want to get rid of this. I have included cla(handles.axes2) in my code, but this does just reset the primary axes. So, how can I reset both the primary and secondary axes? How can I get a handle on the secondary axes?
Here is a minimum example of my code:
cla(handles.axes2, 'reset');
data = [1250,2.5e-11;1300,2.7e-11;1350,7.1e-11;1400,7.2e-11;1450,1.1e-10];
xdata2 = data(:,1)+273;
ydata2 = data(:,2);
T_C = [1600:-100:500];
T_K = T_C+273;
xtick = 10000./T_K;
axes(handles.axes2)
h3 = semilogy(10000./xdata2, ydata2, 'k*');
xlabel('10000/T [K]', 'FontSize',12,'FontWeight','bold')
ylabel('log(D)', 'FontSize',12,'FontWeight','bold')
ax1 = gca;
ax1.XLim = [5.5 11];
ax1.Box = 'off';
ax1_pos = ax1.Position; % position of first axes
ax1_lim = ax1.XLim;
ax2 = axes(...
'XAxisLocation','top',...
'YAxisLocation','right',...
'XTick', [],...
'XLim',ax1_lim, ...
'Units', 'character',...
'Color','none');
set(ax2, 'Position', ax1_pos, 'XTick', xtick, 'XTickLabel', T_C, 'YTick', []) % 'XDir','Reverse'
xlabel('Temperature (°C)', 'FontSize',12,'FontWeight','bold')
hold off
Of course this example will not run on its own as it needs the axes of my GUI etc. But you do get an idea. If would do this outside of the GUI, the figure would be overwritten completely each time, so there would be no problem.
I'd be very happy, if somebody could point me into the right direction. Thanks a lot!

Answers (0)

Categories

Find more on MATLAB 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!