Matlab绘图Tips

1. 不显示 x 坐标轴刻度

set(gca,'xtick',[]);

2. 坐标轴的刻度朝外

set(gca,'TickDir','out')

3. 绘制单个点

1
2
3
x=100;
y=100;
plot(x, y, '+')

4. Y轴反向(0刻度在上,往下递增)

1
2
ax = gca; % current axes
ax.YDir = 'reverse';

5. 将X轴的标度显示在上方

1
ax.XAxisLocation = 'top';

6. 只在左侧,和上侧显示标度

1
ax.Box = 'off';

示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
clear;
close all;
v=[3 3 6 6 5 5 7 7];
z=[0 2 2 10 10 12 12 20];
figure;
plot(v,z)
xlabel('P-VELOCITY KM/SEC');
ylabel('DEPTH IN KM');
ax = gca; % current axes
ax.YDir = 'reverse';
axis([2 9 0 20]);
ax.XTick = 2:1:9;
ax.YTick = 0:10:20
ax.XTickLabel = {'2','','4','','6','','8',''};
ax.XAxisLocation = 'top';
ax.TickDir = 'out';
ax.Box = 'off';
print('./V-Z.eps','-depsc')

VZ.png

7. 用matlab绘制不带白边的图

1
imshow(image,'border','tight')
您的支持将是我前进的不懈动力