Hello and welcome to another video on histograms. This video will provide you with more options for customizing a histogram
and discuss further details of transformation. First, let's load the packages we'll need and import our data.
We'll be importing directly from the web so the code will look a little different than usual. First we'll import pandas
as PD and matplotlib.pyplot as PLT because we'll be creating a plot below.
Next, we'll set our URL to the location where a data is located. Then we'll
use PD.Read_table and use the URL as the argument for where to get the data from.
Read table is being used because we have a dot-dat file.
Okay, let's go ahead and run that line and you can see now we've got some data here below.
Next, let's make two variables. One for RTSec and one for a newly transformed variable, TranRTSec.
In this case, we want to multiply every value of RTSec by 1.5. So to make RTSec, we'll
just set RTSec equal to figure 3-1 brackets RT-sec. This will
just give us a little shortcut to refer to it as later, so we don't have to keep typing out
this very long name of that variable. TranRTSec or transformed RTSec
will be the same as RTSec times 1.5.
Okay, now we're setting up the plot. Because we're making two histograms, we're setting our figure
size equal to 10,6. If you're just making one histogram, you don't need to worry about this step here.
Then we'll plot the first histogram using PLT.Hist, the same as we did before,
setting X labels and titles. Then we'll be plotting our second histogram. So
this lets it know that this is in the first spot. This is in the second spot.
And then we'll show our plots. Now the reason we're doing two plots is so that you can see,
even though we've transformed RT-SEC, our distributions look the same. And the reason for this
is that we've transformed RT-SEC using a linear transformation. Anytime you apply a linear transformation
to a variable, your distribution will remain the same.
All right, that's it for figure 3.1. Good luck with your homework and have fun coding!