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

2 ビュー (過去 30 日間)
Mr M.
Mr M. 2015 年 7 月 7 日
編集済み: Thorsten 2015 年 7 月 8 日
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 Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by