1
00:00:00,480 --> 00:00:03,600
So let's continue discussing other type of plots.

2
00:00:04,620 --> 00:00:10,050
So here you have seen how two plots, two dimensional data, so an X coordinate and the Y coordinate,

3
00:00:10,050 --> 00:00:10,800
for example.

4
00:00:11,580 --> 00:00:16,500
And we have also encountered here our example where we had X, Y and Z coordinates.

5
00:00:17,010 --> 00:00:21,570
But of course, this was a bit of a problem because we could only make two separate plots, which we

6
00:00:21,570 --> 00:00:26,940
have then combined into one plots, but it's not really a three dimensional representation.

7
00:00:28,020 --> 00:00:31,200
What we can do instead is to use a so-called density plot.

8
00:00:31,890 --> 00:00:38,640
So, for example, if you think of when you go hiking and you have some map of a mountain, then you

9
00:00:38,640 --> 00:00:42,180
often see these type of density or contour plots.

10
00:00:42,810 --> 00:00:48,360
And here you have the X and Y coordinates, which are really spatial coordinates.

11
00:00:48,720 --> 00:00:53,490
And then the Z coordinate is the height of the profile of the mountain.

12
00:00:54,300 --> 00:01:01,470
And we will do here something very similar, and we will use density or control plots to plot three

13
00:01:01,470 --> 00:01:02,400
dimensional data.

14
00:01:03,540 --> 00:01:09,900
So the first thing that we are going to do is we are going to have to discuss a bit more about arrays.

15
00:01:10,560 --> 00:01:19,770
So you see plotting, especially in Python, is often related to handling arrays and even multi-dimensional

16
00:01:19,770 --> 00:01:20,220
arrays.

17
00:01:20,850 --> 00:01:27,330
And this is really the most difficult thing about plotting to really have to syntax correct and to manipulate

18
00:01:27,330 --> 00:01:30,030
these arrays so that they fit the correct syntax.

19
00:01:31,020 --> 00:01:34,020
And so, for example, what we had previously was something like this.

20
00:01:35,790 --> 00:01:38,000
I don't know why there is this mistake here.

21
00:01:38,010 --> 00:01:39,930
Let's try it again.

22
00:01:40,470 --> 00:01:41,190
OK, now it's gone.

23
00:01:41,550 --> 00:01:42,150
So we right?

24
00:01:42,150 --> 00:01:46,880
And he got a little space for linear space.

25
00:01:47,340 --> 00:01:50,880
Basically, a list or an array starting from zero to five.

26
00:01:51,210 --> 00:01:54,810
And we want to have six values here, which gives us something like this.

27
00:01:56,190 --> 00:01:58,650
Now let's use two of these.

28
00:02:01,070 --> 00:02:08,270
And, for example, for the other one, I think other values, let's just use five to 10 and also six

29
00:02:08,270 --> 00:02:08,720
steps.

30
00:02:09,470 --> 00:02:14,720
And now we are going to use a non-paid method called and p dot Magritte.

31
00:02:16,310 --> 00:02:22,520
So let's fix the syntax here, and I would say, Yeah, let's do it like this.

32
00:02:23,420 --> 00:02:29,330
So now we have used the command and mesh grid on these two grids or on these two arrays.

33
00:02:30,020 --> 00:02:37,190
And what it does is it basically spans a whole space for the coordinates.

34
00:02:38,690 --> 00:02:46,940
So if we would now transpose this by writing dot t, sorry, that's not working because it's the wrong

35
00:02:46,940 --> 00:02:47,510
syntax.

36
00:02:48,530 --> 00:02:54,530
Let me show you what I mean here, if we would right and p dot transpose.

37
00:02:57,680 --> 00:03:00,620
Which basically means reorder the whole thing.

38
00:03:02,910 --> 00:03:05,410
And then what we get is this.

39
00:03:05,680 --> 00:03:10,420
So then we combine this value and this value and so on and so on.

40
00:03:10,990 --> 00:03:21,070
So it means now we have 25 data points which contain basically the numbers that are spent by these two

41
00:03:21,070 --> 00:03:21,760
lists here.

42
00:03:22,540 --> 00:03:30,200
So, you know, we have this list, we have another list which was this one here, and this will be

43
00:03:30,220 --> 00:03:33,450
our X-axis who are the coordinates go from zero to five.

44
00:03:33,460 --> 00:03:36,890
And this will be all why access where the coordinates go from five to 10.

45
00:03:37,690 --> 00:03:45,760
So we have used mass grids, which we have then transposed to end up with 25 pairs of coordinates where

46
00:03:45,760 --> 00:03:50,380
the X value goes from zero to five and the Y value goes from five to 10.

47
00:03:51,340 --> 00:04:00,700
So now we have really a two dimensional arrow array, which, yeah, which basically describes our range

48
00:04:00,700 --> 00:04:03,190
for which we want to plot the height profile.

49
00:04:03,370 --> 00:04:05,650
So we have the X range and the Y range.

50
00:04:05,950 --> 00:04:07,840
So let's get to the actual example.

51
00:04:08,560 --> 00:04:15,130
So what we're going to do next is we are going to take take this command here and increase basically

52
00:04:15,130 --> 00:04:16,269
the number of points.

53
00:04:17,290 --> 00:04:25,270
And one thing that I forgot to mention is that this year may be, for me, the more reasonable way to

54
00:04:25,270 --> 00:04:27,520
write down the coordinates just pairs of numbers.

55
00:04:27,970 --> 00:04:32,290
But we have seen that actually what we have to provide in these plots.

56
00:04:32,860 --> 00:04:39,670
So just for the scatterplot and also for the upcoming plot is first only the X coordinates and then

57
00:04:39,670 --> 00:04:40,900
only the Y coordinates.

58
00:04:41,620 --> 00:04:48,550
So it turns out, let me scroll down again that this output here has already to correct syntax and we

59
00:04:48,550 --> 00:04:49,570
do not need this one.

60
00:04:50,320 --> 00:04:53,230
So we do not need to transpose one with this one, actually.

61
00:04:54,520 --> 00:04:57,580
So let's delete this and use this one instead.

62
00:04:58,750 --> 00:05:05,340
So basically what we have is we basically have such a thing here.

63
00:05:05,350 --> 00:05:08,470
We can also write it down like this to save a bit of space.

64
00:05:09,010 --> 00:05:14,860
And I would say we go from minus 10 to 10 and 201 points.

65
00:05:15,550 --> 00:05:19,000
And here the same thing, 201 hundred.

66
00:05:20,260 --> 00:05:24,490
And this one will be our coordinates.

67
00:05:24,880 --> 00:05:33,820
And so I would say we just saved them as x, we could say.

68
00:05:33,850 --> 00:05:35,950
I don't know, x two and Y two.

69
00:05:37,240 --> 00:05:42,010
And so if I run this, we have now our lists for the coordinates.

70
00:05:42,010 --> 00:05:47,080
For example, x one or three x two would be all of these coordinates.

71
00:05:48,370 --> 00:05:50,770
So you will see in a second that this really works.

72
00:05:50,950 --> 00:05:57,460
So basically, we have stored now these two individual arrays for the X coordinates Y coordinates in

73
00:05:57,640 --> 00:06:01,180
X two and Y two, and we have increased the number of points.

74
00:06:02,560 --> 00:06:07,060
So now what we're going to do is we are going to generate the actual values for the height.

75
00:06:07,900 --> 00:06:10,000
For this, I will call this Z.

76
00:06:11,110 --> 00:06:13,990
Yeah, we'll call it a Z two and Z two.

77
00:06:14,350 --> 00:06:16,750
Here we just have to provide some kind of function.

78
00:06:17,380 --> 00:06:18,280
It doesn't really matter.

79
00:06:18,280 --> 00:06:24,190
I just take a function x plus y squared.

80
00:06:25,570 --> 00:06:31,900
So you see, this is supposed to be in the raid itself with where every combination of X and Y coordinate

81
00:06:31,900 --> 00:06:33,640
must have, of course, the Z value.

82
00:06:34,060 --> 00:06:36,430
So we have to use here these arrays.

83
00:06:38,390 --> 00:06:45,890
So now when I run this, I can call the Z two, and you see it's a very large array.

84
00:06:47,060 --> 00:06:54,430
It's basically 200 one times 200 one array with all the values of two.

85
00:06:55,670 --> 00:06:57,500
And now we can finally do the plot.

86
00:06:58,430 --> 00:07:02,230
And this you can do by writing down Pulte thoughts control.

87
00:07:03,230 --> 00:07:08,180
And then first at the X coordinates the Y coordinates and then the Z coordinates.

88
00:07:09,260 --> 00:07:11,450
And this will be our results.

89
00:07:12,740 --> 00:07:17,810
So you see, like on a height map, you have these lines where on the line the height is always the

90
00:07:17,810 --> 00:07:18,290
same.

91
00:07:18,650 --> 00:07:23,270
So you see here will probably be the maximum, or it could also be the minimum hard to see.

92
00:07:23,630 --> 00:07:28,670
And then here on these lines, you climb up or down the mountain.

93
00:07:29,570 --> 00:07:32,420
So to find out what is the maximum and the minimum?

94
00:07:32,720 --> 00:07:35,330
It would be a good idea to add a legend.

95
00:07:35,900 --> 00:07:39,050
And here I think we can do even some fancy stuff.

96
00:07:40,070 --> 00:07:45,900
What we can do is we first see this plot and this will give it a name.

97
00:07:45,920 --> 00:07:49,520
Basically, we called it, I don't know, control plot.

98
00:07:51,830 --> 00:07:54,680
And now what we are going to do is we are going to add a legend.

99
00:07:55,040 --> 00:07:59,390
And for this, I write Pulte Dot sea level.

100
00:07:59,780 --> 00:08:03,200
So see label is a special type of label or legend.

101
00:08:03,400 --> 00:08:08,360
And now we first have to provide the type of plots that we want to apply this legend to.

102
00:08:09,230 --> 00:08:11,210
And then just some options.

103
00:08:11,240 --> 00:08:14,250
So you will see in a second look, this does in line equal one.

104
00:08:14,660 --> 00:08:18,890
And then we can also provide some font size for you guys.

105
00:08:18,980 --> 00:08:21,350
Just try like this and let's see.

106
00:08:22,070 --> 00:08:22,620
All right.

107
00:08:22,640 --> 00:08:28,730
So now you see, we have added to every one of those lines the value of the function.

108
00:08:28,970 --> 00:08:30,470
So basically the value of Z.

109
00:08:31,340 --> 00:08:36,620
So this means on this line, all the Z values are the same and they're equal to zero.

110
00:08:37,039 --> 00:08:42,140
And then here in this line, they are 15, which means in this area, the value is between zero and

111
00:08:42,140 --> 00:08:42,590
15.

112
00:08:43,280 --> 00:08:48,620
So actually, this means this is not the hail, this is the bottom, and we have to climb up in this

113
00:08:48,620 --> 00:08:49,160
direction.

114
00:08:50,400 --> 00:08:53,730
All right, so now you see how we can do such a control plot.

115
00:08:54,750 --> 00:09:02,340
We can do also something very similar by using a so-called Contour F plot, which basically means we

116
00:09:02,340 --> 00:09:03,510
fill the area here.

117
00:09:04,590 --> 00:09:05,820
So let me show this to you.

118
00:09:07,620 --> 00:09:08,760
So we will.

119
00:09:08,920 --> 00:09:09,750
Sorry, not here.

120
00:09:10,170 --> 00:09:21,270
We will add a new cell, and here I will name these X three, y three and Z three and function.

121
00:09:21,270 --> 00:09:25,500
Maybe we use a different function here or I have tested before that.

122
00:09:25,500 --> 00:09:26,730
This looks pretty cool.

123
00:09:26,730 --> 00:09:36,210
So let's use cosine function of the X coordinate plus the Y coordinate, and then let's add a linear

124
00:09:36,210 --> 00:09:37,290
function to it.

125
00:09:37,800 --> 00:09:46,470
Zero point zero five Maybe some spaces here zero point zero five times and then X coordinates minus

126
00:09:47,430 --> 00:09:48,240
y coordinate.

127
00:09:49,560 --> 00:09:55,980
So yeah, this is how we generate our data, the X and Y values and the corresponding Z values.

128
00:09:56,580 --> 00:09:58,260
And now we must plot its.

129
00:09:58,410 --> 00:10:06,750
And for this, I write Potti Dot Contour F for Contour plot, which is filled.

130
00:10:07,530 --> 00:10:12,450
And of course, I must provide now that lists X three y three z three.

131
00:10:13,140 --> 00:10:16,200
And we run this and we have this nice plot.

132
00:10:17,100 --> 00:10:17,880
So what does it mean?

133
00:10:18,090 --> 00:10:20,730
Well, we can just add a legend is a what color bar.

134
00:10:21,120 --> 00:10:24,420
And yeah, apparently here it's really easy to do this.

135
00:10:24,690 --> 00:10:27,540
So we just tried to collaborate with no arguments.

136
00:10:28,170 --> 00:10:29,820
And we have to call a bar to the right.

137
00:10:30,690 --> 00:10:38,580
So you see, now you can read the value of Z, which could be the height of a mountain, for example,

138
00:10:39,150 --> 00:10:39,990
from this legend.

139
00:10:40,050 --> 00:10:44,130
So here for the yellow color, it's pretty high and here it's low for the blue color.

140
00:10:45,450 --> 00:10:52,680
So these are two nice methods to visualize three dimensional data like you would do for a height map

141
00:10:52,680 --> 00:10:55,620
or some topographical data map.

142
00:10:56,190 --> 00:11:01,080
And these types of plots are called density plots or contour plots.

