Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to draw a rectangle behind a curve

Subject: how to draw a rectangle behind a curve

From: Konst

Date: 27 Nov, 2010 14:46:03

Message: 1 of 3

I have these commandsQ
X=(a matrix)
plot (X)
i=1;
while i>=1;
[x,y] = ginput(2); % select two points on the curve
get(gco,'Type');
TF=strcmp(get(gco,'Type'),'line'); % TF=0 for a point outside the curve
   if TF==0
       saveas (gcf,'diagramma.fig');
       saveas (gcf,'diagramma.jpg');
        table1=[x1; x2; d;]
        table1=table1'
        break;
    end
x1(i)=x(1);
x2(i)=x(2);
d(i)=x(2)-x(1)
axis manual
rectangle('Position',[x(1),0,x(2)-x(1),1],'Curvature',[0,0],'EdgeColor',[1,0,0])
pause;
i=i+1;
end
This draws the rectangle each time in front of the curve X so the lines of the curve that intersect with the rectangle are not visible. How can I do the opposite?That is, I need to put the rectangle behind the curve so that if I select the poin of their intersection I get the properties(line style, color etc) of the curve and not the rectangle...Any ideas?

Subject: how to draw a rectangle behind a curve

From: Grzegorz Knor

Date: 27 Nov, 2010 16:20:04

Message: 2 of 3

"Konst " <konstance1@hotmail.com> wrote in message <icr5jb$e7v$1@fred.mathworks.com>...
> I have these commandsQ
> X=(a matrix)
> plot (X)
> i=1;
> while i>=1;
> [x,y] = ginput(2); % select two points on the curve
> get(gco,'Type');
> TF=strcmp(get(gco,'Type'),'line'); % TF=0 for a point outside the curve
> if TF==0
> saveas (gcf,'diagramma.fig');
> saveas (gcf,'diagramma.jpg');
> table1=[x1; x2; d;]
> table1=table1'
> break;
> end
> x1(i)=x(1);
> x2(i)=x(2);
> d(i)=x(2)-x(1)
> axis manual
> rectangle('Position',[x(1),0,x(2)-x(1),1],'Curvature',[0,0],'EdgeColor',[1,0,0])
> pause;
> i=i+1;
> end
> This draws the rectangle each time in front of the curve X so the lines of the curve that intersect with the rectangle are not visible. How can I do the opposite?That is, I need to put the rectangle behind the curve so that if I select the poin of their intersection I get the properties(line style, color etc) of the curve and not the rectangle...Any ideas?

My ide is as follows:

plot(1:10,'k','LineWidth',3)

[x y] = ginput(4);
hold on;
fill(x,y,'r')

ch = get(gca,'Children');
set(gca,'Children',ch(end:-1:1))

Does that solve your problem?

Subject: how to draw a rectangle behind a curve

From: Konst

Date: 27 Nov, 2010 17:03:04

Message: 3 of 3

 It does at some point..Thank you very much I'll work with this for now. It must be sufficient!

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us