Reposition x axis

When you use a function plotin Matlab, you are presented with the y and x axes on the left and bottom, respectively. But I would like the x axis to break through in the middle of the figure with such scales and numbers:

enter image description here

I apologize for my amateur drawing skills. But basically I want the x axis to move up, for example, and I want to have numbers there and those small strokes, as indicated on the red line, but everything is to the right, but I do not want the number under each “hit” to be only integers numbers. I tried to answer Google but did not find anything.

It is clear that I do not want two axes along the x axis, so ideally the one below will disappear.

+4
source share
2 answers

, ( FEX), , , Matlab. , . , , Inkscape Illustrator /pgfplots/Matlab 2Tikz .

2014b , . , , , , .

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';

enter image description here

+3

, , Matlab . , .

Matlab Central

t=linspace(0,10,100);plot(t,sin(2*pi*t));
axis([-10 10 -1 1]);

y=get(gca,'ytick');
x=get(gca,'xtick');
hold on
Lx=line([x(1) x(11)],[0 0]);
Ly=line([0 0],[y(1) y(11)]);
set(Lx,'color',[1 0 0]);
set(Ly,'color',[1 0 0]);
for i=1:length(x)
    plot(x(i),0,'k*',0,y(i),'k*');
    text(x(i),-.05,num2str(x(i)));
    text(-1,y(i),num2str(y(i)));
end
set(gca,'yticklabel',[],'xticklabel',[],'ytick',[],'xtick',[]);
set(gca,'visible','off')

matlab figure

fileexchange, , , .

0

Source: https://habr.com/ru/post/1615881/


All Articles