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

2 vues (au cours des 30 derniers jours)
Mr M.
Mr M. le 7 Juil 2015
Modifié(e) : Thorsten le 8 Juil 2015
Is it possible to plot the small tics marks perpendicular to the axes, but not the x and y-axes?
  1 commentaire
Mr M.
Mr M. le 7 Juil 2015
Its very strange. Because it is possible to draw the axes without tics :) And how to change the visibility of the axes?

Connectez-vous pour commenter.

Réponses (1)

Thorsten
Thorsten le 7 Juil 2015
Modifié(e) : Thorsten le 8 Juil 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

Catégories

En savoir plus sur Line Plots 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