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:
Plot

Subject: Plot

From: Jerry

Date: 16 Nov, 2012 22:45:22

Message: 1 of 2

Hello,

A=rand (30,1);
I would like to plot "A" in this way

barh (A) but in this way

A(1:5,1), blue
A(6:15,1), red
A(16:end,1), green

Thanks,
Jerry

Subject: Plot

From: dpb

Date: 17 Nov, 2012 19:50:48

Message: 2 of 2

On 11/16/2012 4:45 PM, Jerry wrote:
> Hello,
>
> A=rand (30,1);
> I would like to plot "A" in this way
>
> barh (A) but in this way
>
> A(1:5,1), blue
> A(6:15,1), red
> A(16:end,1), green

One way is as you wrote, basically...

barh([1:5],A(1:5,'b'))
hold on
barh([6:15],A(6:15,'r'))
barh([16:length(A)],A(16:end,'g'))
set(gca,'ytick',[1 5:5:30])

You can probably dive into the handles and figure out how to set the
patch colors or use colormap or other more sophisticated ways, but...

--

Tags for 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