修改x轴位置 [英] Modify x-axis position

查看:104
本文介绍了修改x轴位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Matlab中使用plot函数时,分别在左侧和底部显示y和x轴.但是我希望x轴以这样的比例和数字穿过图形的中间:

When you use plot function in Matlab, you are presented with y and x axis on the left and at the bottom respectively. But I'd like the x-axis to strike through in the middle of the figure with the scales and numbers like so:

请原谅我的业余绘画技能.但是基本上,我希望例如x轴移动到顶部,并且我希望在那里有数字和那些小凸起,如红线所示,但一直到右边,但是我不希望每个数字都在下面碰撞"只是整数.我试图用谷歌搜索答案,但找不到任何东西.

I beg a pardon for my amateur paint skills. But basically I want the x-axis to move to the top for example and I want to have numbers there and those small bumps like indicated on the red line but all the way through to the right, but I do not want a number under each "bump" just the whole numbers. I tried to google the answer but couldn't find anything.

很明显,我不需要两个x轴,所以理想情况下,底部的一个会消失.

Clearly, I do not want two x-axis, so ideally the one at the bottom would be gone.

推荐答案

通常,除了一些难看的hackhack解决方案(可以在 FEX ),则所需的功能不适用于Matlab.似乎并非如此,它随着最近的更新而发生了变化.因此,如果您真的需要这样做,请将图形另存为矢量图形,并使用Inkscape或Illustrator对其进行编辑,或者从一开始就使用Latex/pgfplots/Matlab2Tikz进行绘制.

Generally, apart from some ugly hackish solutions (can be found on FEX), the functionality you want is not applicable in Matlab. And it doesn't seem so, that it changed with the recent update. So if you really need that, save your figure as vector graphic and edit it with Inkscape or Illustrator, or just draw it with Latex/pgfplots/Matlab2Tikz from the beginning.

不过,图形引擎的2014b更新使用一些 引入了以下解决方案未记录的功能 .也许这已经足够了,我敢说这是无需对手机座进行编码就可以得到的最接近的东西.

However the 2014b update of the graphics engine introduced the following solution using some undocumented features. Maybe this is already sufficient, I dare to say it's the closest you can get without coding handstands.

需要Matlab R2014b或更高版本!

%// example
t = linspace(0,4*pi);
plot(t,sin(t))
ylim([-1.5,1.5]); xlim([0,4*pi]);

%// get handle
h = gca;

%// modify y-axis
h.YBaseline.BaseValue = 0.5;
h.YBaseline.Visible = 'on'; 
h.XRuler.Axle.Visible = 'off';

%// modify x-axis
h.XBaseline.BaseValue = 2;
h.XBaseline.Visible = 'on';
h.YRuler.Axle.Visible = 'off';

这篇关于修改x轴位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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