So let's continue discussing other type of plots.
So here you have seen how two plots, two dimensional data, so an X coordinate and the Y coordinate,
for example.
And we have also encountered here our example where we had X, Y and Z coordinates.
But of course, this was a bit of a problem because we could only make two separate plots, which we
have then combined into one plots, but it's not really a three dimensional representation.
What we can do instead is to use a so-called density plot.
So, for example, if you think of when you go hiking and you have some map of a mountain, then you
often see these type of density or contour plots.
And here you have the X and Y coordinates, which are really spatial coordinates.
And then the Z coordinate is the height of the profile of the mountain.
And we will do here something very similar, and we will use density or control plots to plot three
dimensional data.
So the first thing that we are going to do is we are going to have to discuss a bit more about arrays.
So you see plotting, especially in Python, is often related to handling arrays and even multi-dimensional
arrays.
And this is really the most difficult thing about plotting to really have to syntax correct and to manipulate
these arrays so that they fit the correct syntax.
And so, for example, what we had previously was something like this.
I don't know why there is this mistake here.
Let's try it again.
OK, now it's gone.
So we right?
And he got a little space for linear space.
Basically, a list or an array starting from zero to five.
And we want to have six values here, which gives us something like this.
Now let's use two of these.
And, for example, for the other one, I think other values, let's just use five to 10 and also six
steps.
And now we are going to use a non-paid method called and p dot Magritte.
So let's fix the syntax here, and I would say, Yeah, let's do it like this.
So now we have used the command and mesh grid on these two grids or on these two arrays.
And what it does is it basically spans a whole space for the coordinates.
So if we would now transpose this by writing dot t, sorry, that's not working because it's the wrong
syntax.
Let me show you what I mean here, if we would right and p dot transpose.
Which basically means reorder the whole thing.
And then what we get is this.
So then we combine this value and this value and so on and so on.
So it means now we have 25 data points which contain basically the numbers that are spent by these two
lists here.
So, you know, we have this list, we have another list which was this one here, and this will be
our X-axis who are the coordinates go from zero to five.
And this will be all why access where the coordinates go from five to 10.
So we have used mass grids, which we have then transposed to end up with 25 pairs of coordinates where
the X value goes from zero to five and the Y value goes from five to 10.
So now we have really a two dimensional arrow array, which, yeah, which basically describes our range
for which we want to plot the height profile.
So we have the X range and the Y range.
So let's get to the actual example.
So what we're going to do next is we are going to take take this command here and increase basically
the number of points.
And one thing that I forgot to mention is that this year may be, for me, the more reasonable way to
write down the coordinates just pairs of numbers.
But we have seen that actually what we have to provide in these plots.
So just for the scatterplot and also for the upcoming plot is first only the X coordinates and then
only the Y coordinates.
So it turns out, let me scroll down again that this output here has already to correct syntax and we
do not need this one.
So we do not need to transpose one with this one, actually.
So let's delete this and use this one instead.
So basically what we have is we basically have such a thing here.
We can also write it down like this to save a bit of space.
And I would say we go from minus 10 to 10 and 201 points.
And here the same thing, 201 hundred.
And this one will be our coordinates.
And so I would say we just saved them as x, we could say.
I don't know, x two and Y two.
And so if I run this, we have now our lists for the coordinates.
For example, x one or three x two would be all of these coordinates.
So you will see in a second that this really works.
So basically, we have stored now these two individual arrays for the X coordinates Y coordinates in
X two and Y two, and we have increased the number of points.
So now what we're going to do is we are going to generate the actual values for the height.
For this, I will call this Z.
Yeah, we'll call it a Z two and Z two.
Here we just have to provide some kind of function.
It doesn't really matter.
I just take a function x plus y squared.
So you see, this is supposed to be in the raid itself with where every combination of X and Y coordinate
must have, of course, the Z value.
So we have to use here these arrays.
So now when I run this, I can call the Z two, and you see it's a very large array.
It's basically 200 one times 200 one array with all the values of two.
And now we can finally do the plot.
And this you can do by writing down Pulte thoughts control.
And then first at the X coordinates the Y coordinates and then the Z coordinates.
And this will be our results.
So you see, like on a height map, you have these lines where on the line the height is always the
same.
So you see here will probably be the maximum, or it could also be the minimum hard to see.
And then here on these lines, you climb up or down the mountain.
So to find out what is the maximum and the minimum?
It would be a good idea to add a legend.
And here I think we can do even some fancy stuff.
What we can do is we first see this plot and this will give it a name.
Basically, we called it, I don't know, control plot.
And now what we are going to do is we are going to add a legend.
And for this, I write Pulte Dot sea level.
So see label is a special type of label or legend.
And now we first have to provide the type of plots that we want to apply this legend to.
And then just some options.
So you will see in a second look, this does in line equal one.
And then we can also provide some font size for you guys.
Just try like this and let's see.
All right.
So now you see, we have added to every one of those lines the value of the function.
So basically the value of Z.
So this means on this line, all the Z values are the same and they're equal to zero.
And then here in this line, they are 15, which means in this area, the value is between zero and
15.
So actually, this means this is not the hail, this is the bottom, and we have to climb up in this
direction.
All right, so now you see how we can do such a control plot.
We can do also something very similar by using a so-called Contour F plot, which basically means we
fill the area here.
So let me show this to you.
So we will.
Sorry, not here.
We will add a new cell, and here I will name these X three, y three and Z three and function.
Maybe we use a different function here or I have tested before that.
This looks pretty cool.
So let's use cosine function of the X coordinate plus the Y coordinate, and then let's add a linear
function to it.
Zero point zero five Maybe some spaces here zero point zero five times and then X coordinates minus
y coordinate.
So yeah, this is how we generate our data, the X and Y values and the corresponding Z values.
And now we must plot its.
And for this, I write Potti Dot Contour F for Contour plot, which is filled.
And of course, I must provide now that lists X three y three z three.
And we run this and we have this nice plot.
So what does it mean?
Well, we can just add a legend is a what color bar.
And yeah, apparently here it's really easy to do this.
So we just tried to collaborate with no arguments.
And we have to call a bar to the right.
So you see, now you can read the value of Z, which could be the height of a mountain, for example,
from this legend.
So here for the yellow color, it's pretty high and here it's low for the blue color.
So these are two nice methods to visualize three dimensional data like you would do for a height map
or some topographical data map.
And these types of plots are called density plots or contour plots.