Problem Drawing Independent Variable Axis & Grid
Samuel Doughty <[email protected]> Wed, 27 Sep 2023 11:44:15 -0500
| Newsgroups | gmane.comp.gnu.octave.general |
|---|---|
| Message-ID | <CALCCG3gYXX7v1BBixoKUTJqYg96tpeGPXfP-wEhv1zVVYwUW_w@mail.gmail.com> |
--===============8705466274397449323==
Content-Type: multipart/alternative; boundary="00000000000089ede6060659e715"
--00000000000089ede6060659e715
Content-Type: text/plain; charset="UTF-8"
Gentlemen:
The code below is a portion of an Octave m-file for the solution of a 2nd
order ODE. The solution is generated just fine, but the graphical output is
not working entirely correctly. In figure(1), the time axis is correctly
drawn, but if I activate the similar commands to draw the time axis in
either of the subplots under figure(2), the main curve is removed. Also,
the grid is not present in the upper subplot, despite the fact that grid on
is active. Is this a bug, or an error on my part? Can you give me a fix,
please? Thanks,
Sam
figure(1); clf; hold on; grid on % two normalized curves
plot(t,x1/x1mx,'k-',"LineWidth",2,t,x2/x2mx,'r-')
plot([0 tmx],[0 0],'k',"LineWidth",1) % draw t-axis
xlabel("time, t sec")
title("Normalized Response Curves","fontsize",20)
figure(2); % using two subplots
hold on; grid on
subplot(2, 1, 1); % two rows, one column, first row
plot(t, x1,'k',"LineWidth",2);
%plot([0 tmx],[0 0],'k',"LineWidth",1) % draw t-axis WIPES OUT THE MAIN
CURVE
xlabel("t (sec)");
ylabel("x(t)")
title("Solution Curve, x(t)","fontsize",20);
subplot(2, 1, 2); % two rows, one column, second row
grid on % THIS DOES NOT SEEM TO WORK!!!!
plot(t, x2,'k',"LineWidth",2);
%plot([0 tmx],[0 0],'k',"LineWidth",1) % draw t-axis WIPES OUT THE MAIN
CURVE
xlabel("t (sec)");
ylabel("xdot(t)");
title("First Derivative, xdot(t)","fontsize",20);
--00000000000089ede6060659e715
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:comic sa=
ns ms,sans-serif;font-size:large"><br></div><div class=3D"gmail_default" st=
yle=3D"font-family:comic sans ms,sans-serif;font-size:large">Gentlemen:</di=
v><div class=3D"gmail_default" style=3D"font-family:comic sans ms,sans-seri=
f;font-size:large"><br></div><div class=3D"gmail_default" style=3D"font-fam=
ily:comic sans ms,sans-serif;font-size:large">The code below is a portion o=
f an Octave m-file for the solution of a 2nd order ODE. The solution is gen=
erated just fine, but the graphical output is not working entirely correctl=
y. In figure(1), the time axis is correctly drawn, but if I activate the si=
milar commands to draw the time axis in either of the subplots under figure=
(2), the main curve is removed. Also, the grid is not present in the upper =
subplot, despite the fact that grid on is active.=C2=A0=C2=A0 Is this a bug=
, or an error on my part? Can you give me a fix, please? Thanks,</div><div =
class=3D"gmail_default" style=3D"font-family:comic sans ms,sans-serif;font-=
size:large"><br></div><div class=3D"gmail_default" style=3D"font-family:com=
ic sans ms,sans-serif;font-size:large">Sam</div><div class=3D"gmail_default=
" style=3D"font-family:comic sans ms,sans-serif;font-size:large"><br></div>=
<div class=3D"gmail_default" style=3D"font-family:comic sans ms,sans-serif;=
font-size:large"><br></div><div class=3D"gmail_default" style=3D"font-famil=
y:comic sans ms,sans-serif;font-size:large">figure(1); clf; hold on; grid o=
n =C2=A0% two normalized curves<br>plot(t,x1/x1mx,'k-',"LineWi=
dth",2,t,x2/x2mx,'r-')<br>plot([0 tmx],[0 0],'k',"=
;LineWidth",1) =C2=A0 % draw t-axis<br>xlabel("time, t sec")=
<br>title("Normalized Response Curves","fontsize",20)<b=
r><br>figure(2); =C2=A0 % using two subplots<br>hold on; =C2=A0grid on<br>s=
ubplot(2, 1, 1); =C2=A0% two rows, one column, first row<br>plot(t, x1,'=
;k',"LineWidth",2);<br>%plot([0 tmx],[0 0],'k',"=
LineWidth",1) =C2=A0 % draw t-axis =C2=A0 WIPES OUT THE MAIN CURVE<br>=
xlabel("t (sec)");<br>ylabel("x(t)")<br>title("Sol=
ution Curve, x(t)","fontsize",20);<br><br>subplot(2, 1, 2); =
=C2=A0% two rows, one column, second row<br>grid on =C2=A0 % THIS DOES NOT =
SEEM TO WORK!!!!<br>plot(t, x2,'k',"LineWidth",2);<br>%pl=
ot([0 tmx],[0 0],'k',"LineWidth",1) =C2=A0 % draw t-axis =
=C2=A0WIPES OUT THE MAIN CURVE<br>xlabel("t (sec)");<br>ylabel(&q=
uot;xdot(t)");<br>title("First Derivative, xdot(t)","fo=
ntsize",20);</div></div>
--00000000000089ede6060659e715--
--===============8705466274397449323==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline
Ci0tLS0tLS0tLS0KV2UgYXJlIHRyYW5zaXRpb25pbmcgdG8gYSB3ZWIgYmFzZWQgZm9ydW0KZm9y
IGNvbW11bml0eSBoZWxwIGRpc2N1c3Npb25zIGF0Cmh0dHBzOi8vb2N0YXZlLmRpc2NvdXJzZS5n
cm91cC9jL2hlbHAK
--===============8705466274397449323==--