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:
Plotting values in boxes

Subject: Plotting values in boxes

From: David

Date: 7 Mar, 2012 12:10:38

Message: 1 of 6

Hi,

I have a 6x9 matrix and I want to plot the values so that there are 54 squares and each has its corresponding value.
I have used the contourf function but as expected it doesn't come out correctly.
I'm not sure if there is a graphic function that will do this?

Thanks for any help,
Dave

Subject: Plotting values in boxes

From: Pekka Kumpulainen

Date: 7 Mar, 2012 13:33:12

Message: 2 of 6

"David " <sum_is_41@hotmail.com> wrote in message <jj7j7u$nqj$1@newscl01ah.mathworks.com>...
> Hi,
>
> I have a 6x9 matrix and I want to plot the values so that there are 54 squares and each has its corresponding value.
> I have used the contourf function but as expected it doesn't come out correctly.
> I'm not sure if there is a graphic function that will do this?
>
> Thanks for any help,
> Dave

If you want to have squares coloured by the values: doc imagesc
If you want to print the the numeric values: doc text (and sprintf or num2str)
hth

Subject: Plotting values in boxes

From: David

Date: 7 Mar, 2012 17:27:16

Message: 3 of 6

> If you want to have squares coloured by the values: doc imagesc
> If you want to print the the numeric values: doc text (and sprintf or num2str)
> hth

Thanks for the help; turned out I just needed to use the 'pcolor' graphical function!

Subject: Plotting values in boxes

From: matt dash

Date: 7 Mar, 2012 17:59:11

Message: 4 of 6

"David " <sum_is_41@hotmail.com> wrote in message <jj85pk$sg2$1@newscl01ah.mathworks.com>...
> > If you want to have squares coloured by the values: doc imagesc
> > If you want to print the the numeric values: doc text (and sprintf or num2str)
> > hth
>
> Thanks for the help; turned out I just needed to use the 'pcolor' graphical function!

But note that with 6x9 data, pcolor will produce 5x8 boxes. Imagesc will produce 6x9 boxes.

Subject: Plotting values in boxes

From: David

Date: 8 Mar, 2012 10:27:11

Message: 5 of 6

"matt dash" wrote in message <jj87lf$5ie$1@newscl01ah.mathworks.com>...
> "David " <sum_is_41@hotmail.com> wrote in message <jj85pk$sg2$1@newscl01ah.mathworks.com>...
> > > If you want to have squares coloured by the values: doc imagesc
> > > If you want to print the the numeric values: doc text (and sprintf or num2str)
> > > hth
> >
> > Thanks for the help; turned out I just needed to use the 'pcolor' graphical function!
>
> But note that with 6x9 data, pcolor will produce 5x8 boxes. Imagesc will produce 6x9 boxes.

That is a good point I didn't realise that. However when I use imagesc the y axis is upside down making the data useless.
Is there a simple way of flipping it so that it is the same as pcolor?

Subject: Plotting values in boxes

From: David

Date: 8 Mar, 2012 10:35:18

Message: 6 of 6

Don't worry I worked it out. Use the code set(gca,'YDir','normal').

Thanks for the help guys!

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