f

#### How can I plot two curves with two different y-axis (placed at right and left) with one reverse-logarithmic x-axis?

```How can I plot two curves with two different y-axis (placed at right and left) with one reverse-logarithmic x-axis?

Something like this BUT with a reverse x-axis for both curves:

x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'semilogx');

Thanks!
```
 0
Amir
4/29/2010 12:45:20 PM
comp.soft-sys.matlab 211264 articles. 25 followers. lunamoonmoon (257) is leader.

4 Replies
992 Views

Similar Articles

[PageSpeed] 12

```"Amir " <albalbaloo@gmail.com> wrote in message <hrbv10\$3ti\$1@fred.mathworks.com>...
> How can I plot two curves with two different y-axis (placed at right and left) with one reverse-logarithmic x-axis?
>
> Something like this BUT with a reverse x-axis for both curves:
>
> x = 0:0.01:20;
> y1 = 200*exp(-0.05*x).*sin(x);
> y2 = 0.8*exp(-0.5*x).*sin(10*x);
> [AX,H1,H2] = plotyy(x,y1,x,y2,'semilogx');
>
> Thanks!

one of the solutions

% create your plot, then
set(AX,'xdir','reverse');

us
```
 0
us
4/29/2010 1:01:08 PM
```"us " <us@neurol.unizh.ch> wrote in message <hrbvuk\$4b3\$1@fred.mathworks.com>...
> "Amir " <albalbaloo@gmail.com> wrote in message <hrbv10\$3ti\$1@fred.mathworks.com>...
> > How can I plot two curves with two different y-axis (placed at right and left) with one reverse-logarithmic x-axis?
> >
> > Something like this BUT with a reverse x-axis for both curves:
> >
> > x = 0:0.01:20;
> > y1 = 200*exp(-0.05*x).*sin(x);
> > y2 = 0.8*exp(-0.5*x).*sin(10*x);
> > [AX,H1,H2] = plotyy(x,y1,x,y2,'semilogx');
> >
> > Thanks!
>
> one of the solutions
>
> % create your plot, then
>      set(AX,'xdir','reverse');
>
> us

Thanks, I knew this. The problem with  this command is: it will just reverse (x,y1) set and not  (x,y2) set.
```
 0
Amir
4/29/2010 1:15:21 PM
```"Amir " <albalbaloo@gmail.com> wrote in message <hrc0p9\$sr7\$1@fred.mathworks.com>...
> "us " <us@neurol.unizh.ch> wrote in message <hrbvuk\$4b3\$1@fred.mathworks.com>...
> > "Amir " <albalbaloo@gmail.com> wrote in message <hrbv10\$3ti\$1@fred.mathworks.com>...
> > > How can I plot two curves with two different y-axis (placed at right and left) with one reverse-logarithmic x-axis?
> > >
> > > Something like this BUT with a reverse x-axis for both curves:
> > >
> > > x = 0:0.01:20;
> > > y1 = 200*exp(-0.05*x).*sin(x);
> > > y2 = 0.8*exp(-0.5*x).*sin(10*x);
> > > [AX,H1,H2] = plotyy(x,y1,x,y2,'semilogx');
> > >
> > > Thanks!
> >
> > one of the solutions
> >
> > % create your plot, then
> >      set(AX,'xdir','reverse');
> >
> > us
>
> Thanks, I knew this. The problem with  this command is: it will just reverse (x,y1) set and not  (x,y2) set.

Are you sure?  It worked for me.
MATLAB version R2007b.
```
 0
someone
4/29/2010 3:24:04 PM
```"someone" <someone@somewhere.net> wrote in message <hrc8ak\$s7v\$1@fred.mathworks.com>...
> "Amir " <albalbaloo@gmail.com> wrote in message <hrc0p9\$sr7\$1@fred.mathworks.com>...
> > "us " <us@neurol.unizh.ch> wrote in message <hrbvuk\$4b3\$1@fred.mathworks.com>...
> > > "Amir " <albalbaloo@gmail.com> wrote in message <hrbv10\$3ti\$1@fred.mathworks.com>...
> > > > How can I plot two curves with two different y-axis (placed at right and left) with one reverse-logarithmic x-axis?
> > > >
> > > > Something like this BUT with a reverse x-axis for both curves:
> > > >
> > > > x = 0:0.01:20;
> > > > y1 = 200*exp(-0.05*x).*sin(x);
> > > > y2 = 0.8*exp(-0.5*x).*sin(10*x);
> > > > [AX,H1,H2] = plotyy(x,y1,x,y2,'semilogx');
> > > >
> > > > Thanks!
> > >
> > > one of the solutions
> > >
> > > % create your plot, then
> > >      set(AX,'xdir','reverse');
> > >
> > > us
> >
> > Thanks, I knew this. The problem with  this command is: it will just reverse (x,y1) set and not  (x,y2) set.
>
> Are you sure?  It worked for me.
> MATLAB version R2007b.

I am using R2009b and if I run the below lines:

x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'semilogx');
set(AX,'xdir','reverse');

It is working now!! What happened!!
```
 0
Amir
4/29/2010 3:41:04 PM