如何在MATLAB图形中获取轴上的箭头? [英] How to get arrows on axes in MATLAB plot?

查看:108
本文介绍了如何在MATLAB图形中获取轴上的箭头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绘制这样的东西:

x = 0:0.01:10;
f = @(x) 50* 1.6.^(-x-5);
g = @(x) 50* 1.6.^(+x-10);
plot(x, f(x));
hold on
plot(x, g(x));

我无法获得与该图中相似的轴:

I can't manage to get axes similar to the ones in this figure:

我知道我可以删除顶部和右侧的行,例如

I know I can remove the top and right lines like in this question, but I don't know how to get the arrows on the edges.

我不需要其他注释,但是我想删除轴上的刻度.我知道在轴正常"时如何执行此操作,但是我不确定在轴已被操纵后是否必须以其他方式执行该操作.

I don't need the additional annotations, but I would like to remove the ticks on the axes. I know how to do this when the axes are "normal", but I'm not sure if it must be done in another way when the axes are already manipulated.

有人知道该怎么做吗?

推荐答案

好吧,不要说我没有警告过您:)

Well, don't say I didn't warn you :)

% Some bogus functions
f = @(x) 50* 1.6.^(-x-5);
g = @(x) 50* 1.6.^(+x-10);

% Point where they meet
xE = 2.5;
yE = f(xE);

% Plot the bogus functions
figure(1), clf, hold on
x = 0:0.2:5;
plot(x,f(x),'r',  x,g(x),'b', 'linewidth', 2)

% get rid of standard axes decorations
set(gca, 'Xtick', [], 'Ytick', [], 'box', 'off')

% Fix the axes sizes
axis([0 5 0 5])

% the equilibrium point
plot(xE, yE, 'k.', 'markersize', 20)

% the dashed lines
line([xE 0; xE xE], [0 yE; yE yE], 'linestyle', '--', 'color', 'k')

% the arrows
xO = 0.2;  
yO = 0.1;
patch(...
    [5-xO -yO; 5-xO +yO; 5.0 0.0], ...
    [yO 5-xO; -yO 5-xO; 0 5], 'k', 'clipping', 'off')

% the squishy wiggly line pointing to the "equilibrium" text
h = @(x)0.5*(x+0.2) + 0.1*sin((x+0.2)*14);
x = 2.7:0.01:3.5;
plot(x, h(x), 'k', 'linewidth', 2)

% the static texts
text(xE-yO, -0.2, 'Q^*', 'fontweight', 'bold')
text(-2*yO,   yE, 'P^*', 'fontweight', 'bold')
text(-2*yO,    4, 'Price', 'rotation', 90, 'fontsize', 14)
text(    4, -0.2, 'Quantity', 'fontsize', 14)
text(   .5,  4.2, 'Demand', 'fontsize', 14, 'rotation', -55)
text(   4.0,  3.3, 'Supply', 'fontsize', 14, 'rotation', +55)
text(   3.6,  2.1, 'Equilibrium', 'fontsize', 14)

结果:

这篇关于如何在MATLAB图形中获取轴上的箭头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆