categorical bar graph

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

categorical bar graph

Raag Saluja
Hi! I have to make a bar graph and I want to change the x values to names. I tried the Matlab tutorial as I couldn't find that in octave:

x = categorical ({'small', 'medium', 'large', 'extra large')};
x= reordercats (x, {'small', 'medium', 'large', 'extralarge');
y = [5 20 77 19]
bar(x,y)

However, I got an error message. PFA the screenshot. Can you please help? 

Thank you and regards,

Raag Saluja
Research Scholar
Department of Zoology
Faculty of Science
Dayalbagh Educational Institute
Dayalbagh
Agra
INDIA



Screenshot 2019-10-28 at 7.57.16 AM.png (62K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: categorical bar graph

BGreen
On Mon, Oct 28, 2019 at 1:15 AM Raag Saluja <[hidden email]> wrote:
Hi! I have to make a bar graph and I want to change the x values to names. I tried the Matlab tutorial as I couldn't find that in octave:

x = categorical ({'small', 'medium', 'large', 'extra large')};
x= reordercats (x, {'small', 'medium', 'large', 'extralarge');
y = [5 20 77 19]
bar(x,y)

However, I got an error message. PFA the screenshot. Can you please help? 

Thank you and regards,

Raag Saluja
Research Scholar
Department of Zoology
Faculty of Science
Dayalbagh Educational Institute
Dayalbagh
Agra
INDIA


Is this what you wanted? I'm not familiar with categorical in MATLAB.

y = [5 20 77 19];
bar(y);
set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});

The various properties each object have account for most of Octave's flexibility. Sometimes, however, it can be hard to know where to look. In this case, I modified the axes directly - I did not set labels through the bar function. Here are the axes properties I just used.


Reply | Threaded
Open this post in threaded view
|

Re: categorical bar graph

Raag Saluja
This is perfect, thank you! 

On Mon, Oct 28, 2019 at 9:56 PM Brett Green <[hidden email]> wrote:
On Mon, Oct 28, 2019 at 1:15 AM Raag Saluja <[hidden email]> wrote:
Hi! I have to make a bar graph and I want to change the x values to names. I tried the Matlab tutorial as I couldn't find that in octave:

x = categorical ({'small', 'medium', 'large', 'extra large')};
x= reordercats (x, {'small', 'medium', 'large', 'extralarge');
y = [5 20 77 19]
bar(x,y)

However, I got an error message. PFA the screenshot. Can you please help? 

Thank you and regards,

Raag Saluja
Research Scholar
Department of Zoology
Faculty of Science
Dayalbagh Educational Institute
Dayalbagh
Agra
INDIA


Is this what you wanted? I'm not familiar with categorical in MATLAB.

y = [5 20 77 19];
bar(y);
set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});

The various properties each object have account for most of Octave's flexibility. Sometimes, however, it can be hard to know where to look. In this case, I modified the axes directly - I did not set labels through the bar function. Here are the axes properties I just used.


Reply | Threaded
Open this post in threaded view
|

Re: categorical bar graph

Raag Saluja
What do I do if I want to make subplots, with the same xticklabels, please? I tried this:

y1= [5 2 3 1];

y2= [3 2 2 1];

subplot(2,2,1),bar(y1),subplot(2,2,2),bar(y2)

set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});


PFA a screenshot of the output I got.


On Tue, Oct 29, 2019 at 5:12 PM Raag Saluja <[hidden email]> wrote:
This is perfect, thank you! 

On Mon, Oct 28, 2019 at 9:56 PM Brett Green <[hidden email]> wrote:
On Mon, Oct 28, 2019 at 1:15 AM Raag Saluja <[hidden email]> wrote:
Hi! I have to make a bar graph and I want to change the x values to names. I tried the Matlab tutorial as I couldn't find that in octave:

x = categorical ({'small', 'medium', 'large', 'extra large')};
x= reordercats (x, {'small', 'medium', 'large', 'extralarge');
y = [5 20 77 19]
bar(x,y)

However, I got an error message. PFA the screenshot. Can you please help? 

Thank you and regards,

Raag Saluja
Research Scholar
Department of Zoology
Faculty of Science
Dayalbagh Educational Institute
Dayalbagh
Agra
INDIA


Is this what you wanted? I'm not familiar with categorical in MATLAB.

y = [5 20 77 19];
bar(y);
set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});

The various properties each object have account for most of Octave's flexibility. Sometimes, however, it can be hard to know where to look. In this case, I modified the axes directly - I did not set labels through the bar function. Here are the axes properties I just used.



Screenshot 2019-10-29 at 5.26.44 PM.png (94K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: categorical bar graph

BGreen
On Tue, Oct 29, 2019, 7:57 AM Raag Saluja <[hidden email]> wrote:
What do I do if I want to make subplots, with the same xticklabels, please? I tried this:

y1= [5 2 3 1];

y2= [3 2 2 1];

subplot(2,2,1),bar(y1),subplot(2,2,2),bar(y2)

set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});


PFA a screenshot of the output I got.


I'm not at my computer at the moment, but this should do it:

y1= [5 2 3 1];
y2= [3 2 2 1];
subplot(2,2,1)
bar(y1)
set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});
subplot(2,2,2)
bar(y2)
set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});

gca returns the current axes. It refers to the first plot's axes until you create the second plot. Then it refers to the second plot's axes.


Reply | Threaded
Open this post in threaded view
|

Re: categorical bar graph

Raag Saluja
Thank you so much! 

On Tue, Oct 29, 2019 at 5:35 PM Brett Green <[hidden email]> wrote:
On Tue, Oct 29, 2019, 7:57 AM Raag Saluja <[hidden email]> wrote:
What do I do if I want to make subplots, with the same xticklabels, please? I tried this:

y1= [5 2 3 1];

y2= [3 2 2 1];

subplot(2,2,1),bar(y1),subplot(2,2,2),bar(y2)

set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});


PFA a screenshot of the output I got.


I'm not at my computer at the moment, but this should do it:

y1= [5 2 3 1];
y2= [3 2 2 1];
subplot(2,2,1)
bar(y1)
set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});
subplot(2,2,2)
bar(y2)
set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});

gca returns the current axes. It refers to the first plot's axes until you create the second plot. Then it refers to the second plot's axes.


Reply | Threaded
Open this post in threaded view
|

Re: categorical bar graph

BGreen
You're welcome!

- Brett Green

On Tue, Oct 29, 2019, 8:17 AM Raag Saluja <[hidden email]> wrote:
Thank you so much! 

On Tue, Oct 29, 2019 at 5:35 PM Brett Green <[hidden email]> wrote:
On Tue, Oct 29, 2019, 7:57 AM Raag Saluja <[hidden email]> wrote:
What do I do if I want to make subplots, with the same xticklabels, please? I tried this:

y1= [5 2 3 1];

y2= [3 2 2 1];

subplot(2,2,1),bar(y1),subplot(2,2,2),bar(y2)

set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});


PFA a screenshot of the output I got.


I'm not at my computer at the moment, but this should do it:

y1= [5 2 3 1];
y2= [3 2 2 1];
subplot(2,2,1)
bar(y1)
set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});
subplot(2,2,2)
bar(y2)
set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});

gca returns the current axes. It refers to the first plot's axes until you create the second plot. Then it refers to the second plot's axes.


Reply | Threaded
Open this post in threaded view
|

Re: categorical bar graph

Pantxo
In reply to this post by BGreen
BGreen wrote
> On Mon, Oct 28, 2019 at 1:15 AM Raag Saluja &lt;

> saluja.raag@

> &gt; wrote:
>
>> Hi! I have to make a bar graph and I want to change the x values to
>> names.
>> I tried the Matlab tutorial as I couldn't find that in octave:
>>
>> x = categorical ({'small', 'medium', 'large', 'extra large')};
>> x= reordercats (x, {'small', 'medium', 'large', 'extralarge');
>> y = [5 20 77 19]
>> bar(x,y)
>>
>> However, I got an error message. PFA the screenshot. Can you please help?
>>
>> Thank you and regards,
>>
>> Raag Saluja
>> Research Scholar
>> Department of Zoology
>> Faculty of Science
>> Dayalbagh Educational Institute
>> Dayalbagh
>> Agra
>> INDIA
>>
>
>
> Is this what you wanted? I'm not familiar with categorical in MATLAB.
>
> y = [5 20 77 19];
> bar(y);
> set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});
>
> The various properties each object have account for most of Octave's
> flexibility. Sometimes, however, it can be hard to know where to look. In
> this case, I modified the axes directly - I did not set labels through the
> bar function. Here are the axes properties
> &lt;https://octave.org/doc/v4.2.0/Axes-Properties.html&gt; I just used.

Don't know if it is intensional, but you are providing a link to the doc for
Octave 4.2. The correct web link for the current version, 5.1, is
https://octave.org/doc/interpreter/Axes-Properties.html#Axes-Properties

Now if you are using Octave 5.1 with its GUI, then a more ecological
approach (no web, no server request) is to run the following at the prompt
which should open the page in the doc browser  

doc "axes properties"

Pantxo



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: categorical bar graph

BGreen
Thank you for pointing that out!

- Brett Green


On Tue, Oct 29, 2019 at 9:44 AM Pantxo <[hidden email]> wrote:
BGreen wrote
> On Mon, Oct 28, 2019 at 1:15 AM Raag Saluja &lt;

> saluja.raag@

> &gt; wrote:
>
>> Hi! I have to make a bar graph and I want to change the x values to
>> names.
>> I tried the Matlab tutorial as I couldn't find that in octave:
>>
>> x = categorical ({'small', 'medium', 'large', 'extra large')};
>> x= reordercats (x, {'small', 'medium', 'large', 'extralarge');
>> y = [5 20 77 19]
>> bar(x,y)
>>
>> However, I got an error message. PFA the screenshot. Can you please help?
>>
>> Thank you and regards,
>>
>> Raag Saluja
>> Research Scholar
>> Department of Zoology
>> Faculty of Science
>> Dayalbagh Educational Institute
>> Dayalbagh
>> Agra
>> INDIA
>>
>
>
> Is this what you wanted? I'm not familiar with categorical in MATLAB.
>
> y = [5 20 77 19];
> bar(y);
> set(gca,"xticklabel",{'small', 'medium', 'large', 'extra large'});
>
> The various properties each object have account for most of Octave's
> flexibility. Sometimes, however, it can be hard to know where to look. In
> this case, I modified the axes directly - I did not set labels through the
> bar function. Here are the axes properties
> &lt;https://octave.org/doc/v4.2.0/Axes-Properties.html&gt; I just used.

Don't know if it is intensional, but you are providing a link to the doc for
Octave 4.2. The correct web link for the current version, 5.1, is
https://octave.org/doc/interpreter/Axes-Properties.html#Axes-Properties

Now if you are using Octave 5.1 with its GUI, then a more ecological
approach (no web, no server request) is to run the following at the prompt
which should open the page in the doc browser 

doc "axes properties"

Pantxo



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html