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:
Ticks on dual axis ...

Subject: Ticks on dual axis ...

From: Paul

Date: 7 Dec, 2007 01:27:49

Message: 1 of 17

I'm plotting dual axis (left, right) and I need to
selectively remove the tick marks from opposite axis or the
plot looks like someone tried to zip together two unequal
zippers.

In other words, I only want ticks on the left hand side of
the plot and NOT the right hand side (and vice versa for
the right had plot).

Is there some kind of 'mirror' option in axes that will
allow this? I can't find anything and the only remaining
option is to export to Adobe and treat/amend the figure as
artwork.

Subject: Ticks on dual axis ...

From: Steven Lord

Date: 7 Dec, 2007 02:43:50

Message: 2 of 17


"Paul " <par@ceri.memphis.edu> wrote in message
news:fja7ik$4fg$1@fred.mathworks.com...
> I'm plotting dual axis (left, right) and I need to
> selectively remove the tick marks from opposite axis or the
> plot looks like someone tried to zip together two unequal
> zippers.
>
> In other words, I only want ticks on the left hand side of
> the plot and NOT the right hand side (and vice versa for
> the right had plot).
>
> Is there some kind of 'mirror' option in axes that will
> allow this? I can't find anything and the only remaining
> option is to export to Adobe and treat/amend the figure as
> artwork.

It sounds like you want PLOTYY.

--
Steve Lord
slord@mathworks.com

Subject: Ticks on dual axis ...

From: Paul

Date: 7 Dec, 2007 04:45:37

Message: 3 of 17

"Steven Lord" <slord@mathworks.com> wrote in message
<fjac16$5sr$1@fred.mathworks.com>...
>
> "Paul " <par@ceri.memphis.edu> wrote in message
> news:fja7ik$4fg$1@fred.mathworks.com...
> > I'm plotting dual axis (left, right) and I need to
> > selectively remove the tick marks from opposite axis or the
> > plot looks like someone tried to zip together two unequal
> > zippers.
> >
> > In other words, I only want ticks on the left hand side of
> > the plot and NOT the right hand side (and vice versa for
> > the right had plot).
> >
> > Is there some kind of 'mirror' option in axes that will
> > allow this? I can't find anything and the only remaining
> > option is to export to Adobe and treat/amend the figure as
> > artwork.
>
> It sounds like you want PLOTYY.
>
> --
> Steve Lord
> slord@mathworks.com
>
>

No ... I tired plotyy and found that I had lack of control
over the axis.

All I want is to turn of the ticks on opposing axis! Is
that too much to ask from a plotting routine?

Subject: Ticks on dual axis ...

From: Steven Lord

Date: 7 Dec, 2007 14:52:18

Message: 4 of 17


"Paul " <par@ceri.memphis.edu> wrote in message
news:fjaj5h$bll$1@fred.mathworks.com...
> "Steven Lord" <slord@mathworks.com> wrote in message
> <fjac16$5sr$1@fred.mathworks.com>...
>>
>> "Paul " <par@ceri.memphis.edu> wrote in message
>> news:fja7ik$4fg$1@fred.mathworks.com...
>> > I'm plotting dual axis (left, right) and I need to
>> > selectively remove the tick marks from opposite axis or the
>> > plot looks like someone tried to zip together two unequal
>> > zippers.
>> >
>> > In other words, I only want ticks on the left hand side of
>> > the plot and NOT the right hand side (and vice versa for
>> > the right had plot).
>> >
>> > Is there some kind of 'mirror' option in axes that will
>> > allow this? I can't find anything and the only remaining
>> > option is to export to Adobe and treat/amend the figure as
>> > artwork.
>>
>> It sounds like you want PLOTYY.
>>
>> --
>> Steve Lord
>> slord@mathworks.com
>>
>>
>
> No ... I tired plotyy and found that I had lack of control
> over the axis.

The first output argument from PLOTYY contains the handles of the two axes
it creates; from there, you can use just about any function that accepts an
axes handle to control them. [Performing certain operations (like changing
the limits of one of the axes or zooming one axes) may cause the locations
of the ticks on the two sides to fall out of sync.]

> All I want is to turn of the ticks on opposing axis! Is
> that too much to ask from a plotting routine?

If you have the handles to your axes, modify the YTick and/or YTickLabel
properties of those axes. [I know the URL mentions XTick, but that section
of the documentation talks about the three properties XTick, YTick, ZTick as
a group since the only difference between the three is which axis they
affect.]

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#XTick

Note that if you want the ticks to be at exactly the same heights on the
left and right sides of the axes, PLOTYY will perform that synchronization
for you -- if you don't want to use PLOTYY, you will need to synchronize
them.

--
Steve Lord
slord@mathworks.com

Subject: Ticks on dual axis ...

From: Joseph MacGregor

Date: 24 Mar, 2008 18:20:19

Message: 5 of 17

It would be a lot easier on everyone if there was simply a
axis property switch to turn off the ticks on one side,
rather than force the use of an awkward function like plotyy.

Thanks,

Joe

Subject: Ticks on dual axis ...

From: someone

Date: 24 Mar, 2008 22:06:29

Message: 6 of 17

"Joseph MacGregor" <blah@blah.com> wrote in message <fs8rd3
$b0f$1@fred.mathworks.com>...
> It would be a lot easier on everyone if there was simply a
> axis property switch to turn off the ticks on one side,
> rather than force the use of an awkward function like
plotyy.
>
> Thanks,
>
> Joe

Once you have a handle to the Y axis you want, just set its
Ytick property to an empty vector, [].

Subject: Ticks on dual axis ...

From: someone

Date: 24 Mar, 2008 22:06:29

Message: 7 of 17

"Joseph MacGregor" <blah@blah.com> wrote in message <fs8rd3
$b0f$1@fred.mathworks.com>...
> It would be a lot easier on everyone if there was simply a
> axis property switch to turn off the ticks on one side,
> rather than force the use of an awkward function like
plotyy.
>
> Thanks,
>
> Joe

Once you have a handle to the Y axis you want, just set its
Ytick property to an empty vector, [].

Subject: Ticks on dual axis ...

From: someone

Date: 24 Mar, 2008 22:06:30

Message: 8 of 17

"Joseph MacGregor" <blah@blah.com> wrote in message <fs8rd3
$b0f$1@fred.mathworks.com>...
> It would be a lot easier on everyone if there was simply a
> axis property switch to turn off the ticks on one side,
> rather than force the use of an awkward function like
plotyy.
>
> Thanks,
>
> Joe

Once you have a handle to the Y axis you want, just set its
Ytick property to an empty vector, [].

Subject: Ticks on dual axis ...

From: someone

Date: 24 Mar, 2008 22:07:13

Message: 9 of 17

"Joseph MacGregor" <blah@blah.com> wrote in message <fs8rd3
$b0f$1@fred.mathworks.com>...
> It would be a lot easier on everyone if there was simply a
> axis property switch to turn off the ticks on one side,
> rather than force the use of an awkward function like
plotyy.
>
> Thanks,
>
> Joe

Once you have a handle to the Y axis you want, just set its
Ytick property to an empty vector, [].

Subject: Ticks on dual axis ...

From: someone

Date: 24 Mar, 2008 22:07:13

Message: 10 of 17

"Joseph MacGregor" <blah@blah.com> wrote in message <fs8rd3
$b0f$1@fred.mathworks.com>...
> It would be a lot easier on everyone if there was simply a
> axis property switch to turn off the ticks on one side,
> rather than force the use of an awkward function like
plotyy.
>
> Thanks,
>
> Joe

Once you have a handle to the Y axis you want, just set its
Ytick property to an empty vector, [].

Subject: Ticks on dual axis ...

From: Onur Kerimoglu

Date: 10 Jun, 2008 13:27:02

Message: 11 of 17

"someone " <someone@somewhere.net> wrote in message
<fs98mg$5u$1@fred.mathworks.com>...
> "Joseph MacGregor" <blah@blah.com> wrote in message <fs8rd3
> $b0f$1@fred.mathworks.com>...
> > It would be a lot easier on everyone if there was simply a
> > axis property switch to turn off the ticks on one side,
> > rather than force the use of an awkward function like
> plotyy.
> >
> > Thanks,
> >
> > Joe
>
> Once you have a handle to the Y axis you want, just set its
> Ytick property to an empty vector, [].

Of course that would work, but only if it was that straight
forward to get the handle of the specific 'axis' (not the
axes). Indeed, i found it very surprising that tick marks on
the opposite side is not optional as Joe also mentioned. And
plotyy function is not really taking care of different sets
of tick marks occuring at the same axis, as been claimed.
So, only solution left is that we have to arrange tick
spacings such that they overlap, a solution which cannot be
automatized easily..

Subject: Ticks on dual axis ...

From: Zhelyazko

Date: 17 Jun, 2008 02:03:38

Message: 12 of 17

You just need the axes handle.
So this should work:
[AX,H1,H2] = PLOTYY(...)

Left
set(AX(1),'ytick',[]);
Right one
set(AX(2),'ytick',[]);

"Onur Kerimoglu" <onurkerim@gmail.com> wrote in message
<g2lvf6$321$1@fred.mathworks.com>...
> "someone " <someone@somewhere.net> wrote in message
> <fs98mg$5u$1@fred.mathworks.com>...
> > "Joseph MacGregor" <blah@blah.com> wrote in message <fs8rd3
> > $b0f$1@fred.mathworks.com>...
> > > It would be a lot easier on everyone if there was simply a
> > > axis property switch to turn off the ticks on one side,
> > > rather than force the use of an awkward function like
> > plotyy.
> > >
> > > Thanks,
> > >
> > > Joe
> >
> > Once you have a handle to the Y axis you want, just set its
> > Ytick property to an empty vector, [].
>
> Of course that would work, but only if it was that straight
> forward to get the handle of the specific 'axis' (not the
> axes). Indeed, i found it very surprising that tick marks on
> the opposite side is not optional as Joe also mentioned. And
> plotyy function is not really taking care of different sets
> of tick marks occuring at the same axis, as been claimed.
> So, only solution left is that we have to arrange tick
> spacings such that they overlap, a solution which cannot be
> automatized easily..

Subject: Ticks on dual axis ...

From: Paul

Date: 17 Jun, 2008 04:02:05

Message: 13 of 17

Read the previous messages carefully. We are talking about
turning the tick marks off/on on opposing axis for a simple
plot (plot(x,y), e.g. left hand y-axis has ticks and right
hand y-axis does not. At present, then cannot be easily
achieved in Matlab.




"Zhelyazko " <tumbev@va51.stanford.edu> wrote in message
<g3761q$3pi$1@fred.mathworks.com>...
> You just need the axes handle.
> So this should work:
> [AX,H1,H2] = PLOTYY(...)
>
> Left
> set(AX(1),'ytick',[]);
> Right one
> set(AX(2),'ytick',[]);
>
> "Onur Kerimoglu" <onurkerim@gmail.com> wrote in message
> <g2lvf6$321$1@fred.mathworks.com>...
> > "someone " <someone@somewhere.net> wrote in message
> > <fs98mg$5u$1@fred.mathworks.com>...
> > > "Joseph MacGregor" <blah@blah.com> wrote in message
<fs8rd3
> > > $b0f$1@fred.mathworks.com>...
> > > > It would be a lot easier on everyone if there was
simply a
> > > > axis property switch to turn off the ticks on one side,
> > > > rather than force the use of an awkward function like
> > > plotyy.
> > > >
> > > > Thanks,
> > > >
> > > > Joe
> > >
> > > Once you have a handle to the Y axis you want, just
set its
> > > Ytick property to an empty vector, [].
> >
> > Of course that would work, but only if it was that straight
> > forward to get the handle of the specific 'axis' (not the
> > axes). Indeed, i found it very surprising that tick marks on
> > the opposite side is not optional as Joe also mentioned. And
> > plotyy function is not really taking care of different sets
> > of tick marks occuring at the same axis, as been claimed.
> > So, only solution left is that we have to arrange tick
> > spacings such that they overlap, a solution which cannot be
> > automatized easily..
>

Subject: Ticks on dual axis ...

From: Zhelyazko

Date: 18 Jun, 2008 01:29:03

Message: 14 of 17

Sorry for that.
I don't know if that is what you are trying to do.
But you can turn the Box of the axes to off
So you can have something like.
plot(x,y);
set(gca,'box','off')
so you are going to see only one axes on the left.
set(gca,'YaxisLocation','right');
to move the axis to the right.



"Paul " <par@ceri.memphis.edu> wrote in message
<g37cvt$mv3$1@fred.mathworks.com>...
> Read the previous messages carefully. We are talking about
> turning the tick marks off/on on opposing axis for a simple
> plot (plot(x,y), e.g. left hand y-axis has ticks and right
> hand y-axis does not. At present, then cannot be easily
> achieved in Matlab.
>
>
>
>
> "Zhelyazko " <tumbev@va51.stanford.edu> wrote in message
> <g3761q$3pi$1@fred.mathworks.com>...
> > You just need the axes handle.
> > So this should work:
> > [AX,H1,H2] = PLOTYY(...)
> >
> > Left
> > set(AX(1),'ytick',[]);
> > Right one
> > set(AX(2),'ytick',[]);
> >
> > "Onur Kerimoglu" <onurkerim@gmail.com> wrote in message
> > <g2lvf6$321$1@fred.mathworks.com>...
> > > "someone " <someone@somewhere.net> wrote in message
> > > <fs98mg$5u$1@fred.mathworks.com>...
> > > > "Joseph MacGregor" <blah@blah.com> wrote in message
> <fs8rd3
> > > > $b0f$1@fred.mathworks.com>...
> > > > > It would be a lot easier on everyone if there was
> simply a
> > > > > axis property switch to turn off the ticks on one
side,
> > > > > rather than force the use of an awkward function like
> > > > plotyy.
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Joe
> > > >
> > > > Once you have a handle to the Y axis you want, just
> set its
> > > > Ytick property to an empty vector, [].
> > >
> > > Of course that would work, but only if it was that
straight
> > > forward to get the handle of the specific 'axis' (not the
> > > axes). Indeed, i found it very surprising that tick
marks on
> > > the opposite side is not optional as Joe also
mentioned. And
> > > plotyy function is not really taking care of different
sets
> > > of tick marks occuring at the same axis, as been claimed.
> > > So, only solution left is that we have to arrange tick
> > > spacings such that they overlap, a solution which
cannot be
> > > automatized easily..
> >
>

Subject: Ticks on dual axis ...

From: Paul

Date: 18 Jun, 2008 01:52:01

Message: 15 of 17

Thanks. Your 'solution' seems to work!




"Zhelyazko " <tumbev@va51.stanford.edu> wrote in message
<g39ocv$f9s$1@fred.mathworks.com>...
> Sorry for that.
> I don't know if that is what you are trying to do.
> But you can turn the Box of the axes to off
> So you can have something like.
> plot(x,y);
> set(gca,'box','off')
> so you are going to see only one axes on the left.
> set(gca,'YaxisLocation','right');
> to move the axis to the right.
>
>
>
> "Paul " <par@ceri.memphis.edu> wrote in message
> <g37cvt$mv3$1@fred.mathworks.com>...
> > Read the previous messages carefully. We are talking about
> > turning the tick marks off/on on opposing axis for a simple
> > plot (plot(x,y), e.g. left hand y-axis has ticks and right
> > hand y-axis does not. At present, then cannot be easily
> > achieved in Matlab.
> >
> >
> >
> >
> > "Zhelyazko " <tumbev@va51.stanford.edu> wrote in message
> > <g3761q$3pi$1@fred.mathworks.com>...
> > > You just need the axes handle.
> > > So this should work:
> > > [AX,H1,H2] = PLOTYY(...)
> > >
> > > Left
> > > set(AX(1),'ytick',[]);
> > > Right one
> > > set(AX(2),'ytick',[]);
> > >
> > > "Onur Kerimoglu" <onurkerim@gmail.com> wrote in message
> > > <g2lvf6$321$1@fred.mathworks.com>...
> > > > "someone " <someone@somewhere.net> wrote in message
> > > > <fs98mg$5u$1@fred.mathworks.com>...
> > > > > "Joseph MacGregor" <blah@blah.com> wrote in message
> > <fs8rd3
> > > > > $b0f$1@fred.mathworks.com>...
> > > > > > It would be a lot easier on everyone if there was
> > simply a
> > > > > > axis property switch to turn off the ticks on one
> side,
> > > > > > rather than force the use of an awkward function
like
> > > > > plotyy.
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Joe
> > > > >
> > > > > Once you have a handle to the Y axis you want, just
> > set its
> > > > > Ytick property to an empty vector, [].
> > > >
> > > > Of course that would work, but only if it was that
> straight
> > > > forward to get the handle of the specific 'axis'
(not the
> > > > axes). Indeed, i found it very surprising that tick
> marks on
> > > > the opposite side is not optional as Joe also
> mentioned. And
> > > > plotyy function is not really taking care of different
> sets
> > > > of tick marks occuring at the same axis, as been
claimed.
> > > > So, only solution left is that we have to arrange tick
> > > > spacings such that they overlap, a solution which
> cannot be
> > > > automatized easily..
> > >
> >
>

Subject: Ticks on dual axis ...

From: Willem Jellema

Date: 12 Mar, 2009 12:43:02

Message: 16 of 17

If you still want a dual axis plot with the 'box on' you can consider to use a dummy as follows:

% dummy axes for the box and background color
ax0 = axes;
set (ax0, 'Box', 'on', 'Color', 'white', 'XTick', [], 'YTick', []);

% first axes for left y-axis
ax1 = axes ('Position', get (ax0, 'Position'));
set (ax1, 'Box', 'off', 'Color', 'none', 'YAxisLocation', 'left');

% second axes for right y-axis assuming common x-axis controlled by ax1
ax2 = axes ('Position', get (ax0, 'Position'));
set (ax2, 'Box', 'off', 'Color', 'none', 'XTick', [], 'YAxisLocation', 'right');

Now manipulate ax1 and ax2 as you like, the dual axis plot will appear as you expect intuitively without interfering ticks of left and right y-axes.

Cheers,

Willem

Subject: Ticks on dual axis ...

From: Richard Rieber

Date: 4 Jul, 2011 17:23:09

Message: 17 of 17

Zhelyazko:

I know this is an old thread, but thanks for the help. This solved my "problem" too.

~Rich



"Zhelyazko" wrote in message <g39ocv$f9s$1@fred.mathworks.com>...
> Sorry for that.
> I don't know if that is what you are trying to do.
> But you can turn the Box of the axes to off
> So you can have something like.
> plot(x,y);
> set(gca,'box','off')
> so you are going to see only one axes on the left.
> set(gca,'YaxisLocation','right');
> to move the axis to the right.
>
>
>
> "Paul " <par@ceri.memphis.edu> wrote in message
> <g37cvt$mv3$1@fred.mathworks.com>...
> > Read the previous messages carefully. We are talking about
> > turning the tick marks off/on on opposing axis for a simple
> > plot (plot(x,y), e.g. left hand y-axis has ticks and right
> > hand y-axis does not. At present, then cannot be easily
> > achieved in Matlab.
> >
> >
> >
> >
> > "Zhelyazko " <tumbev@va51.stanford.edu> wrote in message
> > <g3761q$3pi$1@fred.mathworks.com>...
> > > You just need the axes handle.
> > > So this should work:
> > > [AX,H1,H2] = PLOTYY(...)
> > >
> > > Left
> > > set(AX(1),'ytick',[]);
> > > Right one
> > > set(AX(2),'ytick',[]);
> > >
> > > "Onur Kerimoglu" <onurkerim@gmail.com> wrote in message
> > > <g2lvf6$321$1@fred.mathworks.com>...
> > > > "someone " <someone@somewhere.net> wrote in message
> > > > <fs98mg$5u$1@fred.mathworks.com>...
> > > > > "Joseph MacGregor" <blah@blah.com> wrote in message
> > <fs8rd3
> > > > > $b0f$1@fred.mathworks.com>...
> > > > > > It would be a lot easier on everyone if there was
> > simply a
> > > > > > axis property switch to turn off the ticks on one
> side,
> > > > > > rather than force the use of an awkward function like
> > > > > plotyy.
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Joe
> > > > >
> > > > > Once you have a handle to the Y axis you want, just
> > set its
> > > > > Ytick property to an empty vector, [].
> > > >
> > > > Of course that would work, but only if it was that
> straight
> > > > forward to get the handle of the specific 'axis' (not the
> > > > axes). Indeed, i found it very surprising that tick
> marks on
> > > > the opposite side is not optional as Joe also
> mentioned. And
> > > > plotyy function is not really taking care of different
> sets
> > > > of tick marks occuring at the same axis, as been claimed.
> > > > So, only solution left is that we have to arrange tick
> > > > spacings such that they overlap, a solution which
> cannot be
> > > > automatized easily..
> > >
> >
>

Tags for 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