How to remove ticks from the secondary axis in the example below?
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello - Can you help me remove the secondary axis ticks (both in x and y secondary axis) from the code below? Figure attached shows the ticks in primary and secondary axis.
close all; clear; clc; workspace;
%%
data = readmatrix('dddcb.xls', 'sheet', 1, 'Range', 'A3:B400');
first_col1 = data(1:398, 1);
second_col1 = data(1:398, 2);
dose_per_decay1 = second_col1/20000000;
figure(1)
plot(first_col1, dose_per_decay1, 'Color', '[0 0 0]', 'LineWidth',2);
% Make ticks longer and thicker
ax = gca;
properties(ax)
for k = .01 : 0.01 : .02
ax.TickLength = [k, k]; % Make tick marks longer
ax.LineWidth = 50 * k; % Make tick marks thicker
end
ay = gca;
properties(ay)
for k = .01 : 0.01 : .02
ay.TickLength = [k, k];
end
grid off
ax = gca;
ax.XGrid = 'on';
ax.YGrid = 'on';
ax.GridLineStyle = '-';
hAx = gca; % avoid repetitive function calls
set(hAx,'xminorgrid','on','yminorgrid','off') % turn off y-minor grid lines
legend({'\color[rgb]{0 0 0} 3 MeV '}, 'Fontsize', 12);
legend('boxoff')
set(gca,'TickDir','out');
set(gca, 'YScale', 'log');
set(gca, 'XScale', 'log');
set(gca,'FontSize',16, 'XMinorTick','on','YMinorTick','on');
ax = gca;
xlim([1 100]);
ylim([0.000001 100]);
xlabel('distance (\mum)', 'FontSize', 14);
ylabel('dose/decay', 'FontSize', 14);
0 Commenti
Risposta accettata
Voss
il 20 Lug 2022
loglog(1:10000)
ax = gca;
set(ax, ...
'XGrid','on', ...
'YGrid','on', ...
'GridLineStyle','-', ...
'XMinorGrid','on', ...
'YMinorGrid','off', ...
'XMinorTick','off', ...
'YMinorTick','off', ...
'FontSize',16);
5 Commenti
Voss
il 21 Lug 2022
I don't know of a built-in way to have lines on all four sides and ticks on only two sides of the axes, so as far as I know you'll have to do a workaround of one kind or another.
Here's one way you can create the missing black lines on top and right:
loglog(1:10000)
xl = xlim();
yl = ylim();
line('XData',xl([1 2 2]),'YData',yl([2 2 1]),'Color','k');
ax = gca;
set(ax, ...
'Box','off', ...
'XGrid','on', ...
'YGrid','on', ...
'GridLineStyle','-', ...
'XMinorGrid','on', ...
'YMinorGrid','off', ...
'FontSize',16);
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!