Thread Subject: analog of plotyy for bar graphs ??

Subject: analog of plotyy for bar graphs ??

From: Juliette Salexa

Date: 31 Jul, 2009 18:29:02

Message: 1 of 8

This code:

x=[1 3 5 7 9];
y1=[10 25 90 35 16];
K=0.5;
bar1=bar(x, y1, 'FaceColor', 'b', 'EdgeColor', 'b');
set(bar1,'BarWidth',K);
hold on;
y2=[7 38 31 50 41];
bar2=bar(x, y2, 'FaceColor', 'r', 'EdgeColor', 'r');
set(bar2,'BarWidth',K/2);
hold off;
legend('series1','series2')
--------------------------------------------
produces two bar graphs in one figure (one red one blue).
But you see how the red bars only go up to about y=50 ??

I'd like a code that does the EXACT same as the one above, except the red bars are constructed using a different scale, so as to make the red bars also use the full screen.

Is this possible ????

Thanks,
Juliette.

Subject: analog of plotyy for bar graphs ??

From: Juliette Salexa

Date: 31 Jul, 2009 22:33:02

Message: 2 of 8

This got buried under other posts and pushed to page 2, so I'm replying to bring it back up.

I'd be surprised if there's no way to do this! Plotyy has existd for ages.

Subject: analog of plotyy for bar graphs ??

From: us

Date: 31 Jul, 2009 23:06:01

Message: 3 of 8

"Juliette Salexa" <juliette.physicist@gmail.com> wrote in message <h4vreu$od7$1@fred.mathworks.com>...
> This got buried under other posts and pushed to page 2, so I'm replying to bring it back up.

well, this simply means that most CSSMers (for once) have not shown any interest in your particular problem...
note: being pushy does not help... as a matter of fact: it often turns people off...

now - show CSSMers your attempt to solve this menial problem...

us

Subject: analog of plotyy for bar graphs ??

From: Juliette Salexa

Date: 2 Aug, 2009 00:25:03

Message: 4 of 8

1. I don't know what CSSMers means.
2. I didn't mean to sound pushy, I just wanted to push the thread back up because in my experience when it gets pushed to page 2 it doesn't get looked at nearly as much. But I apologize if it looked pushy.

3.
The only ideas I had to solve this problem (after looking through all the examples on the documentation for bar graphs), were trying baryy (which didn't work), and manually scaling all the data in y2 to be in the same range as the range of y1 and then manually labeling the y-axis afterwards.

If there's a way in matlab to automate this process (using simple internal functions, like we can with plotyy) I'd like to know how! ... If anyone has tried this before and found that matlab has no such funciton, then I'll submit a suggestion to MathWorks.

Subject: analog of plotyy for bar graphs ??

From: Matt Fig

Date: 2 Aug, 2009 00:39:02

Message: 5 of 8

Did you search the FEX. That is where I go when I need something that isn't already in MATLAB. It is worth a few minutes to look usually.

Subject: analog of plotyy for bar graphs ??

From: Juliette Salexa

Date: 2 Aug, 2009 00:57:02

Message: 6 of 8

Thanks Matt,

I had done a quick search of the FEX and seemed to only get results relating to "error bars"

But I took your advice and looked more thoroughly!

I found something that looks like it does the job [I'm posting it here in case it helps anyone else asking the same question]:

http://www.mathworks.com/matlabcentral/fileexchange/10839

Before searching the FEX I usually ask here whether or not the function exists internally on matlab, since a lot of files on the FEX do things that could alredy be done easily inside matlab (either in a new version, or even before!).


Thanks again!

Subject: analog of plotyy for bar graphs ??

From: Paul Mennen

Date: 2 Aug, 2009 05:37:03

Message: 7 of 8

"Juliette Salexa" wrote
> I found something that looks like it does the job [I'm posting it here in case it helps anyone else asking the same question]:
> http://www.mathworks.com/matlabcentral/fileexchange/10839

Another one to try is 'plt':

http://www.mathworks.com/matlabcentral/fileexchange/4936

This is a more general alternative to plotyy. The particular example
you should try is "pltvbar" in the demo folder. That example which shows
various styles of vertical bars uses only a single y-axis, although it is trivial
to use two y axes as some of the other examples show.

~Paul

Subject: analog of plotyy for bar graphs ??

From: Steven Lord

Date: 3 Aug, 2009 15:23:04

Message: 8 of 8


"Juliette Salexa" <juliette.physicist@gmail.com> wrote in message
news:h4vreu$od7$1@fred.mathworks.com...
> This got buried under other posts and pushed to page 2, so I'm replying to
> bring it back up.
>
> I'd be surprised if there's no way to do this! Plotyy has existd for ages.

Look at the function1 and function2 inputs to PLOTYY.

--
Steve Lord
slord@mathworks.com

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
scolding us 31 Jul, 2009 19:09:04
rssFeed for this Thread

Contact us at files@mathworks.com