Borrar filtros
Borrar filtros

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

13 visualizaciones (últimos 30 días)
blues
blues el 20 de Jul. de 2022
Comentada: blues el 21 de Jul. de 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);

Respuesta aceptada

Voss
Voss el 20 de Jul. de 2022
loglog(1:10000)
ax = gca;
set(ax, ...
'XGrid','on', ...
'YGrid','on', ...
'GridLineStyle','-', ...
'XMinorGrid','on', ...
'YMinorGrid','off', ...
'XMinorTick','off', ...
'YMinorTick','off', ...
'FontSize',16);
  5 comentarios
Voss
Voss el 21 de Jul. de 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);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by