WEBVTT

00:00:07.527 --> 00:00:09.110
IAN HUTCHINSON: Let's
just finish this

00:00:09.110 --> 00:00:15.220
off by cleaning up this
plot and saving it.

00:00:15.220 --> 00:00:20.760
In the first case, I don't
have any labels on my axes.

00:00:20.760 --> 00:00:22.080
That's bad.

00:00:22.080 --> 00:00:25.790
Let me put some
labels on my axes.

00:00:25.790 --> 00:00:29.930
X-label is the way you do this.

00:00:29.930 --> 00:00:37.490
And in this case I have a
very simple label that I want.

00:00:37.490 --> 00:00:39.670
And the same thing,
presumably for Y-label.

00:00:42.600 --> 00:00:47.020
That will at least
put some labels on.

00:00:47.020 --> 00:00:49.260
Aren't they horribly small?

00:00:49.260 --> 00:00:52.410
But they are there.

00:00:52.410 --> 00:00:57.740
Now, I want to improve
this plot in general.

00:00:57.740 --> 00:01:02.540
Let me point out another
thing that I want to do.

00:01:02.540 --> 00:01:04.940
I don't want to have
hold on permanently,

00:01:04.940 --> 00:01:11.540
so let me put hold off
after the second plot.

00:01:11.540 --> 00:01:14.530
And that's going to avoid
difficulties in the future.

00:01:14.530 --> 00:01:17.500
So I'm just going to save that.

00:01:17.500 --> 00:01:20.350
Now in order to improve
the size of the labels

00:01:20.350 --> 00:01:23.320
and so forth that's
involved with this,

00:01:23.320 --> 00:01:25.800
there are a number
of things one can do.

00:01:25.800 --> 00:01:31.600
And in general, I'm going to
do this for many of my plots.

00:01:31.600 --> 00:01:33.170
And so what I want
to do is I want

00:01:33.170 --> 00:01:37.250
to illustrate the fact
that my script-- which

00:01:37.250 --> 00:01:41.630
is called fitting.m,
can call another script.

00:01:41.630 --> 00:01:45.240
And it can call as
many scripts as I like.

00:01:45.240 --> 00:01:51.030
The script I'm going to call,
I have in my editor already.

00:01:51.030 --> 00:01:54.980
It's called plot defaults.

00:01:54.980 --> 00:01:57.320
Plot defaults.m.

00:01:57.320 --> 00:02:04.700
And here are some
mysterious calls

00:02:04.700 --> 00:02:08.810
that you will find out
only by reading the help

00:02:08.810 --> 00:02:11.050
files in general.

00:02:11.050 --> 00:02:15.530
By the way, in Octave
there's all kinds of help

00:02:15.530 --> 00:02:20.410
that you can find out by
typing things like, help.

00:02:20.410 --> 00:02:27.620
But in general it's more
useful usually to use doc.

00:02:27.620 --> 00:02:30.920
And so we could do
doc, let's say a plat

00:02:30.920 --> 00:02:33.800
and it would then
bring me to a place

00:02:33.800 --> 00:02:37.830
in the documentation, where
the documentation for plot

00:02:37.830 --> 00:02:39.850
is described.

00:02:39.850 --> 00:02:44.340
MathLab has got
its own help system

00:02:44.340 --> 00:02:50.720
and you can use that to
look up various things.

00:02:50.720 --> 00:02:55.170
I could do doc of,
let's say, set,

00:02:55.170 --> 00:02:58.100
and it will show
me what these set

00:02:58.100 --> 00:03:03.800
commands that are in this
file plot defaults are doing.

00:03:03.800 --> 00:03:06.140
The syntax is
complicated and it's not

00:03:06.140 --> 00:03:09.190
worth us dwelling
on it at the moment.

00:03:09.190 --> 00:03:11.500
Let me just explain
what it's going to do.

00:03:11.500 --> 00:03:16.400
First of all it's going to
set the default access label

00:03:16.400 --> 00:03:19.019
font size to be bigger, 20.

00:03:19.019 --> 00:03:20.560
Second thing it's
going to do is it's

00:03:20.560 --> 00:03:26.520
going to make the width of
the lines of the axes two

00:03:26.520 --> 00:03:31.510
instead of one because
the axes on these plots

00:03:31.510 --> 00:03:35.750
may well be better
if they're thicker.

00:03:35.750 --> 00:03:41.750
In general these plots tend to
come up with rather thin lines.

00:03:41.750 --> 00:03:50.840
That's useful generally, but the
most useful thing to fix these

00:03:50.840 --> 00:03:55.310
plots, and to get the labelling
to be a decent size turns out

00:03:55.310 --> 00:03:59.480
to be to shrink the size of
the plot leave the font size

00:03:59.480 --> 00:04:00.550
the same.

00:04:00.550 --> 00:04:06.320
So what this command
does is it basically

00:04:06.320 --> 00:04:12.390
sets the paper units, the paper
orientation, and the paper size

00:04:12.390 --> 00:04:17.320
to be three inches by four
inches, height versus width.

00:04:17.320 --> 00:04:21.290
And then it sets the paper
position in such a way

00:04:21.290 --> 00:04:27.260
that we aren't
writing off the paper.

00:04:27.260 --> 00:04:33.560
As I said, all of this is subtle
and you wouldn't necessarily

00:04:33.560 --> 00:04:35.270
want to know all
the details of this.

00:04:35.270 --> 00:04:39.430
I'll happily make this
file available to you.

00:04:39.430 --> 00:04:46.320
But all I have to do
in order to execute

00:04:46.320 --> 00:04:52.710
those commands in that
file, plot defaults,

00:04:52.710 --> 00:04:55.690
is write the command
plot defaults.

00:04:55.690 --> 00:04:59.180
And I'm going to do that
before my first plot.

00:04:59.180 --> 00:05:03.820
So plot defaults
should read in that

00:05:03.820 --> 00:05:08.400
file that I was just
looking at, this file,

00:05:08.400 --> 00:05:11.430
and execute the commands in it.

00:05:11.430 --> 00:05:15.560
Notice, by the way,
comments, very important.

00:05:15.560 --> 00:05:18.840
Because these commands
are mysterious,

00:05:18.840 --> 00:05:22.830
I put some commentary
to remind you

00:05:22.830 --> 00:05:25.330
what they're supposed to
be doing next to them,

00:05:25.330 --> 00:05:27.680
and the way the
comment is defined

00:05:27.680 --> 00:05:34.730
is by having a percent line
at the beginning of the line,

00:05:34.730 --> 00:05:39.040
or actually anywhere else
in the line for that matter.

00:05:39.040 --> 00:05:39.610
OK.

00:05:39.610 --> 00:05:45.870
Let's save this new
file and run it again.

00:05:45.870 --> 00:05:50.780
And lo and behold it's run.

00:05:50.780 --> 00:05:58.520
Probably-- I may not have
several of the defaults right

00:05:58.520 --> 00:06:01.530
because I've been doing a
number of things in this Octave

00:06:01.530 --> 00:06:03.830
session.

00:06:03.830 --> 00:06:06.260
If I get tired of
this Octave session--

00:06:06.260 --> 00:06:09.735
I've run 25 different commands
on it, it's telling me--

00:06:09.735 --> 00:06:14.360
and I want to
start a fresh, it's

00:06:14.360 --> 00:06:18.479
sometimes helpful to start
a new, fresh session.

00:06:18.479 --> 00:06:20.020
I can do this very
straightforwardly,

00:06:20.020 --> 00:06:23.770
we're just saying, exit, and
then starting over again.

00:06:23.770 --> 00:06:27.980
That's one way to be sure you've
got a nice, fresh session.

00:06:27.980 --> 00:06:30.940
One of the nicest
things about Octave

00:06:30.940 --> 00:06:34.010
is it actually still remembers
what your commands were,

00:06:34.010 --> 00:06:36.080
even though you've
got a new session.

00:06:36.080 --> 00:06:41.920
So here's what the plot
looks like, in the case

00:06:41.920 --> 00:06:47.380
when I run it with plot
defaults and executed before any

00:06:47.380 --> 00:06:49.370
of other plotting commands.

00:06:49.370 --> 00:06:53.200
So the plot defaults needs to
happen before anything else.

00:06:53.200 --> 00:06:57.720
And now what you see is
much better, much bigger

00:06:57.720 --> 00:07:02.370
at any rate labels on the
axes, et cetera, et cetera.

00:07:02.370 --> 00:07:03.290
Things aren't perfect.

00:07:03.290 --> 00:07:07.560
There's a little y is crashed
with the x there, but anyway.

00:07:07.560 --> 00:07:10.490
You can tweak around with
those to your heart's content.

00:07:14.500 --> 00:07:19.470
If this were fine, my final
plot, what I wanted to save,

00:07:19.470 --> 00:07:21.360
one of the ways I
could save it would

00:07:21.360 --> 00:07:24.140
be to do some kind of screen
capture on this window

00:07:24.140 --> 00:07:26.110
that I'm plotting it in.

00:07:26.110 --> 00:07:30.500
That would give me a rather
cumbersome and not very pretty

00:07:30.500 --> 00:07:31.500
plot.

00:07:31.500 --> 00:07:36.710
There is another way of
plotting, of saving this plot.

00:07:36.710 --> 00:07:40.180
And that is to use
the command print.

00:07:40.180 --> 00:07:45.680
So print is actually
printing out the plotting.

00:07:45.680 --> 00:07:49.680
One has to tell print
what format one wants.

00:07:49.680 --> 00:08:01.260
Supposing I want EPS
format, I could say D EPS.

00:08:01.260 --> 00:08:10.950
And suppose that I know what
file I want to save it into,

00:08:10.950 --> 00:08:18.660
I could, for example, write
fitted.EPS, like that.

00:08:18.660 --> 00:08:24.560
So this tells it to print out
this plot into an EPS file,

00:08:24.560 --> 00:08:28.782
which is then named fitted.EPS.

00:08:28.782 --> 00:08:29.740
Let's see what happens.

00:08:32.720 --> 00:08:35.710
Nothing obvious,
except that if I now

00:08:35.710 --> 00:08:40.780
look in the directory, which in
Octave I can do by typing LS,

00:08:40.780 --> 00:08:44.450
there is a file
called fitted EPS.

00:08:44.450 --> 00:08:46.720
I don't want to get out
of my Octave session.

00:08:46.720 --> 00:08:48.560
I'm in the same directory here.

00:08:48.560 --> 00:08:51.780
Here it is, fitted EPS.

00:08:51.780 --> 00:08:55.370
Let's have a look at that
file using ghost view,

00:08:55.370 --> 00:08:56.820
and there it is.

00:08:59.780 --> 00:09:07.840
This is now a good quality
file that I might be

00:09:07.840 --> 00:09:10.190
proud to show to my professor.

00:09:13.390 --> 00:09:16.270
It's actually not in color.

00:09:16.270 --> 00:09:18.740
That's because I use EPS.

00:09:18.740 --> 00:09:21.690
I think it's EPS C for color.

00:09:21.690 --> 00:09:23.390
Let me try it.

00:09:23.390 --> 00:09:28.210
Let's run that again and now
look at it again, and see,

00:09:28.210 --> 00:09:29.560
yes, it's color.

00:09:29.560 --> 00:09:31.820
Now it's color.

00:09:31.820 --> 00:09:36.500
So that's how to get
a plot and to save

00:09:36.500 --> 00:09:40.780
it looking halfway decent.

00:09:40.780 --> 00:09:44.120
And that's where we'll end.