本文介绍了如何在MATLAB图形中显示x和y轴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 plot()函数绘制图形,但默认情况下它不显示轴。
我们如何在图上的x = 0和y = 0处显示轴?
实际上,我的图如下所示:我想要一条水平线对应 y = 0 即可。 显示坐标轴,除非你修改了一些设置。试试以下内容:
hold on; %确保在每个绘图命令上不会创建新的绘图窗口
axes(); %生成绘图窗口的轴
绘图(无论您的绘图命令是多少%);
plot([0 10],[0 0],'k-'); %绘制水平线
I am drawing a graph using the plot() function, but by default it doesn't show the axes.
How do we enable showing the axes at x=0 and y=0 on the graph?
Actually my graph is something like:
And I want a horizontal line corresponding to y=0. How do I get that?
解决方案
By default, plot does show axes, unless you've modified some settings. Try the following
hold on; % make sure no new plot window is created on every plot command
axes(); % produce plot window with axes
plot(% whatever your plot command is);
plot([0 10], [0 0], 'k-'); % plot the horizontal line
这篇关于如何在MATLAB图形中显示x和y轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!