WEBVTT

00:01.250 --> 00:06.330
In this video we are going to plot the data on our Titanic data frame with the method plot.

00:06.350 --> 00:11.730
But first of all let's import pandas and we import our Titanic data set.

00:11.750 --> 00:16.040
So here are the first five rows and some meta information.

00:17.990 --> 00:24.060
And if you want to create some plots and visualizations we first need to import the map plot lip library

00:24.350 --> 00:30.710
which is actually the most popular python library for creating plots and visualizations and actually

00:30.710 --> 00:35.140
as convention we import mad plot lip dubbed pi plot SBT.

00:35.870 --> 00:39.830
So a penalty is actually the most commonly used the previous Asian here.

00:39.860 --> 00:41.220
So let's do this.

00:41.330 --> 00:45.040
Now we want to plot to the numerical columns in our Titanic data frame.

00:45.050 --> 00:47.730
So we have some numerical columns here.

00:47.750 --> 00:55.280
We have this advice column the peak class column the H column space P parts and also the fact column

00:55.880 --> 01:03.050
and we can do this by simply calling here the plot method on our Titanic data frame so far Pena's data

01:03.050 --> 01:07.300
frames and pandas the areas that is the built and method the dot plot.

01:07.400 --> 01:11.360
And before we run the set here we have to also call the show method.

01:11.360 --> 01:11.900
So.

01:12.170 --> 01:15.800
So this is a direct map plot laptop type love method.

01:15.860 --> 01:20.070
And with that the show method we can actually display our graph our plot.

01:20.120 --> 01:25.460
So all of a sudden we create one or several plots of asylum and plug lip as the very last argument we

01:25.460 --> 01:28.120
have to call here the show method.

01:28.160 --> 01:34.690
So let's simply call here the plot method on our entire Titanic data frame and that's from the set here

01:36.930 --> 01:40.240
and here we can see that we actually see nothing.

01:40.680 --> 01:48.110
So by default the plot method creates here a line plot with on the x axis then the index.

01:48.120 --> 01:52.270
So here we have the range index from zero to eight hundred ninety one.

01:52.290 --> 01:58.800
So these are actually the passenger numbers and on the y axis we have actually these specific values

01:58.800 --> 02:03.690
and our numerical columns and for each column we have actually here a line plot.

02:03.780 --> 02:10.250
So we have six columns here and as we have here a six line plots more than one graph within one plot.

02:10.260 --> 02:16.500
That's quite hard to see anything and therefore let's go here inside the brackets.

02:16.580 --> 02:18.050
Let's shift tab.

02:18.060 --> 02:23.970
And here we can see we have a pair of meta subplots and by default it's set to forwards but we can set

02:23.970 --> 02:25.550
this also to true here

02:29.450 --> 02:33.200
and by doing so we're creating for each column a separate subplot.

02:33.260 --> 02:40.370
And still it's hard to see anything because the plot size is very small and that's an additional parameter

02:40.370 --> 02:41.960
here.

02:41.960 --> 02:48.580
And it's called the fixed size and we can determine the width and the height of the graph.

02:48.610 --> 02:50.220
So let's do this here.

02:50.240 --> 02:56.810
We have here fixed size and then we have to pass the then a top of the desired the width and the height

02:56.840 --> 02:57.650
of the graph.

02:57.650 --> 03:02.540
So for example you want to f a bit of twelve and a height of eight

03:05.700 --> 03:13.230
then we get to a larger plot and maybe you should further increase the size here to maybe 15 month 12

03:13.240 --> 03:16.800
of.

03:16.840 --> 03:19.030
So now it's much easier to see and analyze it.

03:19.540 --> 03:22.390
So for each column we have a separate subplot.

03:22.390 --> 03:28.570
So you have for the survival column the plus column the H column the best B column patch column and

03:28.570 --> 03:29.690
fact column.

03:29.840 --> 03:32.860
And by default all the subplots share actually.

03:32.890 --> 03:34.770
The x axis.

03:34.870 --> 03:41.230
So we have here at the very bottom one x axis the width of the Range Index from zero to eight hundred

03:41.230 --> 03:42.180
ninety one.

03:42.310 --> 03:46.110
But we can also create a separate x axis for each subplot.

03:46.120 --> 03:57.160
And that is the one parameter here and the parameter yes share X. So let's have a look here and by default

03:57.160 --> 03:58.910
it's set to true actually.

03:58.960 --> 04:06.020
So all subplots share one x axis but we can also set this to form.

04:06.050 --> 04:08.850
So let's do this.

04:09.940 --> 04:17.420
So we have these share experiments and we can set it to fours and we can see here at the bottom of each

04:17.420 --> 04:18.350
subplot.

04:18.380 --> 04:28.400
The x axis with the arranged index from 0 to 891 and we can see on the left hand side for each subplot

04:28.430 --> 04:30.500
actually the y axis.

04:30.530 --> 04:33.260
And here we have a specific y axis.

04:33.260 --> 04:34.310
For each subplot.

04:34.310 --> 04:40.290
So for example here if this survives column we have values between 0 and 1.

04:40.400 --> 04:47.210
So you can see here it's isolating between 0 and 1 then here for the peak class column we have the values

04:47.240 --> 04:55.670
1 2 and 3 then for the H column we have values between 0 and 80 and the line plot like this is actually

04:55.670 --> 04:58.130
good to see in the distribution of values.

04:58.250 --> 05:02.540
So the majority of ages are yeah between 20 and 40.

05:02.780 --> 05:08.750
But we have some outliers here around zero and some outliers around the 75 80.

05:09.650 --> 05:13.950
And specifically when we have time serious data with a daytime index.

05:14.030 --> 05:17.530
So we have been on the x axis a daytime index.

05:17.540 --> 05:25.040
So for example starting from the year 2010 onto two thousand and fifteen and specifically in this case

05:25.040 --> 05:29.750
a line plot is very intuitive to see the evolution of some factors over time.

05:29.900 --> 05:36.860
So for example stock prices or weather data but also you have a non time serious data a line plot to

05:36.860 --> 05:37.390
the max.

05:37.390 --> 05:44.060
That definitely sentence and here in this FSP column we can see that the majority of fair use are here

05:44.060 --> 05:45.010
actually 1.

05:45.620 --> 05:49.990
So most of the passengers have one sibling or spouse onboard.

05:50.360 --> 05:57.860
And also you have for the parents and children the most frequent values are between 0 and 2 and also

05:57.860 --> 06:05.000
you in the fact column we can see that the most frequent fast are actually quite low year between 0

06:05.000 --> 06:06.380
and 20.

06:06.530 --> 06:08.300
However there are some outliers here.

06:08.300 --> 06:16.040
So we have some outliers onto four or five hundred dollars and we have seen on the left hand side so

06:16.040 --> 06:17.120
fights subplot.

06:17.180 --> 06:22.700
We have a different scale for the y axis but we can also change this year.

06:22.760 --> 06:24.920
So yes that apparently does share y

06:27.990 --> 06:29.240
so we have Y

06:32.460 --> 06:35.160
and by default it's set to fall so far a subplot.

06:35.170 --> 06:41.480
We have a specific and appropriate y axis but we can also set this to a true

06:44.030 --> 06:44.640
a..

06:44.650 --> 06:45.640
For a subplot.

06:45.640 --> 06:49.500
Actually these same y axis with the same scale.

06:50.460 --> 06:55.230
And as we have here the largest scale at the fact column.

06:55.290 --> 07:00.210
So the sad y axis is actually most appropriate here for the fact column.

07:00.210 --> 07:03.730
So here we have values between zero and 500.

07:03.750 --> 07:09.310
However for the patch column a scale between zero and five hundred does not really make sense.

07:09.310 --> 07:11.300
So here we actually see nothing.

07:11.460 --> 07:17.130
And therefore in this case that definitely makes sense to set these shall y Wyatt parameter to fours

07:20.810 --> 07:26.300
and actually if you are only interested in the H column and if you only want to visualize that the H

07:26.300 --> 07:33.440
column you can also apply the plot method only on the H column so let's do this let's copy the code

07:36.890 --> 07:42.770
and instead of using the plot method on the entire Titanic that afraid to use it only on the H column

07:44.060 --> 07:48.070
and if you only use it on the edge column we do not have to define me as subplots.

07:48.140 --> 07:55.580
So this is not necessary and maybe we make the figure a size a bit smaller here because we have only

07:55.580 --> 07:58.660
one subplot.

07:58.880 --> 08:07.020
And also we do not need to do apparently does share X and shall y so let's plotted the graph.

08:07.220 --> 08:14.180
And here we have actually a line plot only for the H column so we can't see the x axis that the index

08:14.180 --> 08:16.390
letters from 0 to 890 is.

08:16.670 --> 08:23.930
And we can see on the by axis values between zero and 80 and the majority of fair use are here between

08:24.050 --> 08:31.810
20 and 40 and we have some very young passengers that are only a bit older than the serial Yes loads

08:31.810 --> 08:38.210
so babies and we have some quite old peasants as above 70 and until 80.

08:38.530 --> 08:39.050
All right.

08:39.050 --> 08:45.770
This was the first video on data visualization and in the next video we learn how to customize our plot

08:45.770 --> 08:46.130
here.

08:46.130 --> 08:48.170
So I hope to see you there by.
