Effacer les filtres
Effacer les filtres

How to remove ticks from the secondary axis in the example below?

13 vues (au cours des 30 derniers jours)
blues
blues le 20 Juil 2022
Commenté : blues le 21 Juil 2022
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);

Réponse acceptée

Voss
Voss le 20 Juil 2022
loglog(1:10000)
ax = gca;
set(ax, ...
'XGrid','on', ...
'YGrid','on', ...
'GridLineStyle','-', ...
'XMinorGrid','on', ...
'YMinorGrid','off', ...
'XMinorTick','off', ...
'YMinorTick','off', ...
'FontSize',16);
  5 commentaires
Voss
Voss le 21 Juil 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);
blues
blues le 21 Juil 2022
Thank you. This worked.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Visual Exploration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by