help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: secondary x axis


From: Jan Potac
Subject: Re: secondary x axis
Date: Mon, 08 Apr 2013 16:23:55 +0200
User-agent: Opera Mail/12.14 (Linux)

On Mon, 08 Apr 2013 14:15:29 +0200, Ben Abbott <address@hidden> wrote:

On Apr 8, 2013, at 4:33 AM, Jan Potac wrote:

Trying to plot a figure with additional x axis on the top of the figure. (x-axis2
= f(x-axis1))
I have found some example but getting plots bit offset. It seems the cause is
the top x label which 'pushes' the second plot to move down due to keeping some
space from bounding box or window size. (if my observation correct)
I have been searching for some set () parameter but not succeeded yet.
Any hint, please?

My code looks like:
f5 = figure(5, "visible", "on");
%x values in radians
hold 'on';
x = [0:0.1:6.3];
%y values values
y=sin(x);
%x values in degrees
x2=180/pi()*(x);
%means each new graph destroys the previous(overlay mode off)
plot(x, y);
hold 'off';
%attach the current axes (gca) to handle "axes1"
axes1=gca;
%ensure x axis at bottom
%see "get(axes1)" for additional properties
%see "set(axes1)" for properties which can be altered
set(axes1, 'XAxisLocation', 'bottom');
%overlay mode on
hold 'on';
%add additional axes
axes;
plot(x2, y);
axes2=gca;
%ensure x axis at top
set(axes2, 'XAxisLocation', 'top' );
%make different intervals
set(axes2, 'XTick', [x2(1):75:x2(length(x2))] );
%overlay off
hold 'off';

Regards,
Jan

Does the attached do what you want?

I've changed the "activepostionproperty", set the "color" of the second axis to "none", removed the yaxis tick labels for the second axes and eliminated all
plot objects from the second axes.

Ben





Ben,
Thank you. It seems to be what I want though still need adjust some thinks like: 1. the sin function disappears after being plot. I think it could be due to overlaying but have not found the solution yet. 2. Similarly, bottom ticks disappear when second axis being set. And the same as on the top are shown instead.

(using Octave version 3.4.0)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]