Is it possible to plot the ticks but not the axes?

2 visualizaciones (últimos 30 días)
Mr M.
Mr M. el 7 de Jul. de 2015
Editada: Thorsten el 8 de Jul. de 2015
Is it possible to plot the small tics marks perpendicular to the axes, but not the x and y-axes?
  1 comentario
Mr M.
Mr M. el 7 de Jul. de 2015
Its very strange. Because it is possible to draw the axes without tics :) And how to change the visibility of the axes?

Iniciar sesión para comentar.

Respuestas (1)

Thorsten
Thorsten el 7 de Jul. de 2015
Editada: Thorsten el 8 de Jul. de 2015
No, but you can draw a white line on top of the axes.
Or you can use my function onlyticks
function onlyticks
%ONLYTICKS Plot only the ticks of the axis.
%
% ONLYTICKS Plot only the ticks of the axis.
% Ticks drawn by ONLYTICKS are unaffected by subsequent calls of
% BOX OFF or AXIS OFF.
%
% Thorsten.Hansen@psychol.uni-giessen.de 2015-07-08
plotsize = min([diff(xlim) diff(ylim)]);
xticklength = 0.015*plotsize;
yticklength = 0.01*plotsize;
% xticks
xpos1 = get(gca, 'XTick');
xpos = flatten([xpos1; xpos1; nan(1,numel(xpos1))])';
ylims = ylim;
ypos = ylims(1) + [0 xticklength];
ypos = repmat([ypos nan(1,1)], [1 numel(xpos1)]);
if strcmp(get(gca, 'Box'), 'on')
% add ticks on top of plot
xpos = [xpos xpos];
ypos = [ypos ypos + diff(ylims) - xticklength];
end
line(xpos(1:end-1), ypos(1:end-1), 'Color', get(gca, 'XColor'))
% yticks
ypos1 = get(gca, 'YTick');
ypos = flatten([ypos1; ypos1; nan(1,numel(ypos1))])';
xlims = xlim;
xpos = xlims(1) + [0 yticklength];
xpos = repmat([xpos nan(1,1)], [1 numel(ypos1)]);
if strcmp(get(gca, 'Box'), 'on')
% add ticks on top of plot
ypos = [ypos ypos];
xpos = [xpos xpos + diff(xlims) - yticklength];
end
line(xpos(1:end-1), ypos(1:end-1), 'Color', get(gca, 'YColor'))
axis off

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by