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

2 次查看(过去 30 天)
Is it possible to plot the small tics marks perpendicular to the axes, but not the x and y-axes?
  1 个评论
Mr M.
Mr M. 2015-7-7
Its very strange. Because it is possible to draw the axes without tics :) And how to change the visibility of the axes?

请先登录,再进行评论。

回答(1 个)

Thorsten
Thorsten 2015-7-7
编辑:Thorsten 2015-7-8
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

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by