Thread Subject: Plot several vertical lines in different colors

Subject: Plot several vertical lines in different colors

From: Thomas

Date: 26 Jun, 2009 07:33:01

Message: 1 of 2

Hi,

I want to plot vertical lines, given the matrix interv_plot (see code below), where the lines are endpoints of an interval. E.g. interv_plot(j,1,k) is the left point of the k-th interval at level j, while interv_plot(j,2,k) is the right endpoint.

Now I found in the web how to generate vertical lines in a plot (don't know if this is optimal), generating imaginary numbers.

What I'd like to have is to autamtically get assigned a different color to every level j, since J also varies, while the different intervals on the same level have the same color.

Any ideas on this?

Thanks

Thomas


for j=1:J
    for k=1:K
        p1 = interv_plot(j,1,k); p2 = interv_plot(j,2,k);
        h1 = p1 + t*i; h2 = p2 + t*i;
        plot(h1, 'm-.', 'Linewidth', 1); plot(h2, 'm-.', 'Linewidth', 1);
    end
end

Subject: Plot several vertical lines in different colors

From: Ravi

Date: 2 Jul, 2009 14:31:01

Message: 2 of 2

"Thomas " <meinl@iism.uni-karlsruhe.de> wrote in message <h21tjd$rbr$1@fred.mathworks.com>...
> Hi,
>
> I want to plot vertical lines, given the matrix interv_plot (see code below), where the lines are endpoints of an interval. E.g. interv_plot(j,1,k) is the left point of the k-th interval at level j, while interv_plot(j,2,k) is the right endpoint.
>
> Now I found in the web how to generate vertical lines in a plot (don't know if this is optimal), generating imaginary numbers.
>
> What I'd like to have is to autamtically get assigned a different color to every level j, since J also varies, while the different intervals on the same level have the same color.
>
> Any ideas on this?
>
> Thanks
>
> Thomas
>
>
> for j=1:J
> for k=1:K
> p1 = interv_plot(j,1,k); p2 = interv_plot(j,2,k);
> h1 = p1 + t*i; h2 = p2 + t*i;
> plot(h1, 'm-.', 'Linewidth', 1); plot(h2, 'm-.', 'Linewidth', 1);
> end
> end


thomas, try this...it works

%interpolate to get J colors
cols = get(0,'defaultaxescolororder');
cols = cols(mod(0:J-1,length(cols))+1,:)


for j=1:J
    for k=1:K
        p1 = interv_plot(j,1,k); p2 = interv_plot(j,2,k);
        h1 = p1 + t*i; h2 = p2 + t*i;
        plot(h1, 'm-.', 'Linewidth', 1, 'color',[cols(j,:)]); plot(h2, 'm-.', 'Linewidth', 1,'color',[cols(j,:)]);
    end
end

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
color Thomas 26 Jun, 2009 04:53:53
vertical line Thomas 26 Jun, 2009 04:53:53
plot Thomas 26 Jun, 2009 04:53:39
rssFeed for this Thread

Contact us at files@mathworks.com