[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
secondary x axis
From: |
Jan Potac |
Subject: |
secondary x axis |
Date: |
Mon, 08 Apr 2013 10:33:12 +0200 |
User-agent: |
Opera Mail/12.14 (Linux) |
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
- secondary x axis,
Jan Potac <=