1 00:00:07,527 --> 00:00:09,110 IAN HUTCHINSON: Let's just finish this 2 00:00:09,110 --> 00:00:15,220 off by cleaning up this plot and saving it. 3 00:00:15,220 --> 00:00:20,760 In the first case, I don't have any labels on my axes. 4 00:00:20,760 --> 00:00:22,080 That's bad. 5 00:00:22,080 --> 00:00:25,790 Let me put some labels on my axes. 6 00:00:25,790 --> 00:00:29,930 X-label is the way you do this. 7 00:00:29,930 --> 00:00:37,490 And in this case I have a very simple label that I want. 8 00:00:37,490 --> 00:00:39,670 And the same thing, presumably for Y-label. 9 00:00:42,600 --> 00:00:47,020 That will at least put some labels on. 10 00:00:47,020 --> 00:00:49,260 Aren't they horribly small? 11 00:00:49,260 --> 00:00:52,410 But they are there. 12 00:00:52,410 --> 00:00:57,740 Now, I want to improve this plot in general. 13 00:00:57,740 --> 00:01:02,540 Let me point out another thing that I want to do. 14 00:01:02,540 --> 00:01:04,940 I don't want to have hold on permanently, 15 00:01:04,940 --> 00:01:11,540 so let me put hold off after the second plot. 16 00:01:11,540 --> 00:01:14,530 And that's going to avoid difficulties in the future. 17 00:01:14,530 --> 00:01:17,500 So I'm just going to save that. 18 00:01:17,500 --> 00:01:20,350 Now in order to improve the size of the labels 19 00:01:20,350 --> 00:01:23,320 and so forth that's involved with this, 20 00:01:23,320 --> 00:01:25,800 there are a number of things one can do. 21 00:01:25,800 --> 00:01:31,600 And in general, I'm going to do this for many of my plots. 22 00:01:31,600 --> 00:01:33,170 And so what I want to do is I want 23 00:01:33,170 --> 00:01:37,250 to illustrate the fact that my script-- which 24 00:01:37,250 --> 00:01:41,630 is called fitting.m, can call another script. 25 00:01:41,630 --> 00:01:45,240 And it can call as many scripts as I like. 26 00:01:45,240 --> 00:01:51,030 The script I'm going to call, I have in my editor already. 27 00:01:51,030 --> 00:01:54,980 It's called plot defaults. 28 00:01:54,980 --> 00:01:57,320 Plot defaults.m. 29 00:01:57,320 --> 00:02:04,700 And here are some mysterious calls 30 00:02:04,700 --> 00:02:08,810 that you will find out only by reading the help 31 00:02:08,810 --> 00:02:11,050 files in general. 32 00:02:11,050 --> 00:02:15,530 By the way, in Octave there's all kinds of help 33 00:02:15,530 --> 00:02:20,410 that you can find out by typing things like, help. 34 00:02:20,410 --> 00:02:27,620 But in general it's more useful usually to use doc. 35 00:02:27,620 --> 00:02:30,920 And so we could do doc, let's say a plat 36 00:02:30,920 --> 00:02:33,800 and it would then bring me to a place 37 00:02:33,800 --> 00:02:37,830 in the documentation, where the documentation for plot 38 00:02:37,830 --> 00:02:39,850 is described. 39 00:02:39,850 --> 00:02:44,340 MathLab has got its own help system 40 00:02:44,340 --> 00:02:50,720 and you can use that to look up various things. 41 00:02:50,720 --> 00:02:55,170 I could do doc of, let's say, set, 42 00:02:55,170 --> 00:02:58,100 and it will show me what these set 43 00:02:58,100 --> 00:03:03,800 commands that are in this file plot defaults are doing. 44 00:03:03,800 --> 00:03:06,140 The syntax is complicated and it's not 45 00:03:06,140 --> 00:03:09,190 worth us dwelling on it at the moment. 46 00:03:09,190 --> 00:03:11,500 Let me just explain what it's going to do. 47 00:03:11,500 --> 00:03:16,400 First of all it's going to set the default access label 48 00:03:16,400 --> 00:03:19,019 font size to be bigger, 20. 49 00:03:19,019 --> 00:03:20,560 Second thing it's going to do is it's 50 00:03:20,560 --> 00:03:26,520 going to make the width of the lines of the axes two 51 00:03:26,520 --> 00:03:31,510 instead of one because the axes on these plots 52 00:03:31,510 --> 00:03:35,750 may well be better if they're thicker. 53 00:03:35,750 --> 00:03:41,750 In general these plots tend to come up with rather thin lines. 54 00:03:41,750 --> 00:03:50,840 That's useful generally, but the most useful thing to fix these 55 00:03:50,840 --> 00:03:55,310 plots, and to get the labelling to be a decent size turns out 56 00:03:55,310 --> 00:03:59,480 to be to shrink the size of the plot leave the font size 57 00:03:59,480 --> 00:04:00,550 the same. 58 00:04:00,550 --> 00:04:06,320 So what this command does is it basically 59 00:04:06,320 --> 00:04:12,390 sets the paper units, the paper orientation, and the paper size 60 00:04:12,390 --> 00:04:17,320 to be three inches by four inches, height versus width. 61 00:04:17,320 --> 00:04:21,290 And then it sets the paper position in such a way 62 00:04:21,290 --> 00:04:27,260 that we aren't writing off the paper. 63 00:04:27,260 --> 00:04:33,560 As I said, all of this is subtle and you wouldn't necessarily 64 00:04:33,560 --> 00:04:35,270 want to know all the details of this. 65 00:04:35,270 --> 00:04:39,430 I'll happily make this file available to you. 66 00:04:39,430 --> 00:04:46,320 But all I have to do in order to execute 67 00:04:46,320 --> 00:04:52,710 those commands in that file, plot defaults, 68 00:04:52,710 --> 00:04:55,690 is write the command plot defaults. 69 00:04:55,690 --> 00:04:59,180 And I'm going to do that before my first plot. 70 00:04:59,180 --> 00:05:03,820 So plot defaults should read in that 71 00:05:03,820 --> 00:05:08,400 file that I was just looking at, this file, 72 00:05:08,400 --> 00:05:11,430 and execute the commands in it. 73 00:05:11,430 --> 00:05:15,560 Notice, by the way, comments, very important. 74 00:05:15,560 --> 00:05:18,840 Because these commands are mysterious, 75 00:05:18,840 --> 00:05:22,830 I put some commentary to remind you 76 00:05:22,830 --> 00:05:25,330 what they're supposed to be doing next to them, 77 00:05:25,330 --> 00:05:27,680 and the way the comment is defined 78 00:05:27,680 --> 00:05:34,730 is by having a percent line at the beginning of the line, 79 00:05:34,730 --> 00:05:39,040 or actually anywhere else in the line for that matter. 80 00:05:39,040 --> 00:05:39,610 OK. 81 00:05:39,610 --> 00:05:45,870 Let's save this new file and run it again. 82 00:05:45,870 --> 00:05:50,780 And lo and behold it's run. 83 00:05:50,780 --> 00:05:58,520 Probably-- I may not have several of the defaults right 84 00:05:58,520 --> 00:06:01,530 because I've been doing a number of things in this Octave 85 00:06:01,530 --> 00:06:03,830 session. 86 00:06:03,830 --> 00:06:06,260 If I get tired of this Octave session-- 87 00:06:06,260 --> 00:06:09,735 I've run 25 different commands on it, it's telling me-- 88 00:06:09,735 --> 00:06:14,360 and I want to start a fresh, it's 89 00:06:14,360 --> 00:06:18,479 sometimes helpful to start a new, fresh session. 90 00:06:18,479 --> 00:06:20,020 I can do this very straightforwardly, 91 00:06:20,020 --> 00:06:23,770 we're just saying, exit, and then starting over again. 92 00:06:23,770 --> 00:06:27,980 That's one way to be sure you've got a nice, fresh session. 93 00:06:27,980 --> 00:06:30,940 One of the nicest things about Octave 94 00:06:30,940 --> 00:06:34,010 is it actually still remembers what your commands were, 95 00:06:34,010 --> 00:06:36,080 even though you've got a new session. 96 00:06:36,080 --> 00:06:41,920 So here's what the plot looks like, in the case 97 00:06:41,920 --> 00:06:47,380 when I run it with plot defaults and executed before any 98 00:06:47,380 --> 00:06:49,370 of other plotting commands. 99 00:06:49,370 --> 00:06:53,200 So the plot defaults needs to happen before anything else. 100 00:06:53,200 --> 00:06:57,720 And now what you see is much better, much bigger 101 00:06:57,720 --> 00:07:02,370 at any rate labels on the axes, et cetera, et cetera. 102 00:07:02,370 --> 00:07:03,290 Things aren't perfect. 103 00:07:03,290 --> 00:07:07,560 There's a little y is crashed with the x there, but anyway. 104 00:07:07,560 --> 00:07:10,490 You can tweak around with those to your heart's content. 105 00:07:14,500 --> 00:07:19,470 If this were fine, my final plot, what I wanted to save, 106 00:07:19,470 --> 00:07:21,360 one of the ways I could save it would 107 00:07:21,360 --> 00:07:24,140 be to do some kind of screen capture on this window 108 00:07:24,140 --> 00:07:26,110 that I'm plotting it in. 109 00:07:26,110 --> 00:07:30,500 That would give me a rather cumbersome and not very pretty 110 00:07:30,500 --> 00:07:31,500 plot. 111 00:07:31,500 --> 00:07:36,710 There is another way of plotting, of saving this plot. 112 00:07:36,710 --> 00:07:40,180 And that is to use the command print. 113 00:07:40,180 --> 00:07:45,680 So print is actually printing out the plotting. 114 00:07:45,680 --> 00:07:49,680 One has to tell print what format one wants. 115 00:07:49,680 --> 00:08:01,260 Supposing I want EPS format, I could say D EPS. 116 00:08:01,260 --> 00:08:10,950 And suppose that I know what file I want to save it into, 117 00:08:10,950 --> 00:08:18,660 I could, for example, write fitted.EPS, like that. 118 00:08:18,660 --> 00:08:24,560 So this tells it to print out this plot into an EPS file, 119 00:08:24,560 --> 00:08:28,782 which is then named fitted.EPS. 120 00:08:28,782 --> 00:08:29,740 Let's see what happens. 121 00:08:32,720 --> 00:08:35,710 Nothing obvious, except that if I now 122 00:08:35,710 --> 00:08:40,780 look in the directory, which in Octave I can do by typing LS, 123 00:08:40,780 --> 00:08:44,450 there is a file called fitted EPS. 124 00:08:44,450 --> 00:08:46,720 I don't want to get out of my Octave session. 125 00:08:46,720 --> 00:08:48,560 I'm in the same directory here. 126 00:08:48,560 --> 00:08:51,780 Here it is, fitted EPS. 127 00:08:51,780 --> 00:08:55,370 Let's have a look at that file using ghost view, 128 00:08:55,370 --> 00:08:56,820 and there it is. 129 00:08:59,780 --> 00:09:07,840 This is now a good quality file that I might be 130 00:09:07,840 --> 00:09:10,190 proud to show to my professor. 131 00:09:13,390 --> 00:09:16,270 It's actually not in color. 132 00:09:16,270 --> 00:09:18,740 That's because I use EPS. 133 00:09:18,740 --> 00:09:21,690 I think it's EPS C for color. 134 00:09:21,690 --> 00:09:23,390 Let me try it. 135 00:09:23,390 --> 00:09:28,210 Let's run that again and now look at it again, and see, 136 00:09:28,210 --> 00:09:29,560 yes, it's color. 137 00:09:29,560 --> 00:09:31,820 Now it's color. 138 00:09:31,820 --> 00:09:36,500 So that's how to get a plot and to save 139 00:09:36,500 --> 00:09:40,780 it looking halfway decent. 140 00:09:40,780 --> 00:09:44,120 And that's where we'll end.