Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: XLABEL.

Subject: XLABEL.

From: Marcus Vinicius Pereira de Souza

Date: 28 Mar, 2008 03:13:02

Message: 1 of 4

Dear all,
I need to plot a graphic where xlabel is variable. Example:

X=[1 2 3;4 5 6;7 8 9];

Y=[10 20 30;40 50 60;70 80 90];

K=[];
M=[];

[m,n]=size(X);

for i=1:m
    for j=1:n
        if i >= j
           K=[K; X(i,j) Y(i,j)]
           M=[M; i j]
        end
   end
end

bar(K)

I need to put the labels on the bar graphic (to this
example):
M1-M1 M2-M1 M2-M2 M3-M1 M3-M2 M3-M3

Do anyone help me?
Thanks a lot!

Subject: Re: XLABEL.

From: Sven

Date: 28 Mar, 2008 07:01:35

Message: 2 of 4

"Marcus Vinicius Pereira de Souza" <mvinic@hotmail.com>
wrote in message <fshnnu$bfs$1@fred.mathworks.com>...
> Dear all,
> I need to plot a graphic where xlabel is variable. Example:
>
> X=[1 2 3;4 5 6;7 8 9];
>
> Y=[10 20 30;40 50 60;70 80 90];
>
> K=[];
> M=[];
>
> [m,n]=size(X);
>
> for i=1:m
> for j=1:n
> if i >= j
> K=[K; X(i,j) Y(i,j)]
> M=[M; i j]
> end
> end
> end
>
> bar(K)
>
> I need to put the labels on the bar graphic (to this
> example):
> M1-M1 M2-M1 M2-M2 M3-M1 M3-M2 M3-M3
>
> Do anyone help me?
> Thanks a lot!
>


Hi Marcus,

Do you mean XTickLabels instead of xlabel?
Running the following command after you call "bar" will give
what (I think) you want.

set(gca,'XTickLabel',{'M1-M1','M2-M1','M2-M2','M3-M1','M3-M2','M3-M3'})

Cheers,
Sven.

Subject: Re: XLABEL.

From: Marcus Vinicius Pereira de Souza

Date: 28 Mar, 2008 13:25:04

Message: 3 of 4

Dear Sven,
Thanks a lot!
By the way, I need to put the labels automatic because my
X (Y) real matrix has size 12 x 12!
Then I have 64 elements!
Seen what I have done:


X=[1 2 3;4 5 6;7 8 9];

Y=[10 20 30;40 50 60;70 80 90];

K=[];
M=[];
[m,n]=size(X);

for i=1:m
    for j=1:n
        
       
        if i > j
           K=[K; X(i,j) Y(i,j)];
           M=[M; i j];
           bar(K)
           a=num2str(i);
           b=num2str(j);
           set(gca,'XTickLabel',{'M{a}-M{b}'})

        end
   end
end

I would like to plot one (8 x 8) subplots too!!
Best regards,
Marcus Vinicius

Subject: Re: XLABEL.

From: Yuri Geshelin

Date: 28 Mar, 2008 14:51:02

Message: 4 of 4

"Marcus Vinicius Pereira de Souza" <mvinic@hotmail.com>
wrote in message <fsirjf$42r$1@fred.mathworks.com>...
> Dear Sven,
> Thanks a lot!
> By the way, I need to put the labels automatic because my
> X (Y) real matrix has size 12 x 12!
> Then I have 64 elements!
> Seen what I have done:
>
>
> X=[1 2 3;4 5 6;7 8 9];
>
> Y=[10 20 30;40 50 60;70 80 90];
>
> K=[];
> M=[];
> [m,n]=size(X);
>
> for i=1:m
> for j=1:n
>
>
> if i > j
> K=[K; X(i,j) Y(i,j)];
> M=[M; i j];
> bar(K)
> a=num2str(i);
> b=num2str(j);
> set(gca,'XTickLabel',{'M{a}-M{b}'})
>
> end
> end
> end
>
> I would like to plot one (8 x 8) subplots too!!
> Best regards,
> Marcus Vinicius
>

Hi,

Nice plot. Normally, to make a plot like this a
presentation quality, you also need to do

set(gca,'fontweight','bold','fontsize',m)

where m is at least 16.

Yuri


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
graphics Marcus Vinicius Pereira de Souza 27 Mar, 2008 23:15:05
labels Marcus Vinicius Pereira de Souza 27 Mar, 2008 23:15:05
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics