Plotting with Matplotlib


import matplotlib.pyplot as plt
yes, that's how we import a sub-package pyplot from Matplotlib

x= [1,2,3,4]
y= [5,6,7,8]
plt.plot(x, y)
plt.show()

when you have a time data it is better to put then in x-axis and calculate linear(line graph) , but when you are calculation correlation between any two variable then you have to use scatter plot than line plot i.e. ,
plt.scatter(x,y)

you can change the scale of plot using.
it scale axis independently
plt.xscale("log")


Histogram 
help(plt.hist)





import matplotlib.pyplot as plt

 x = [1, 3, 6, 3, 2, 7, 3, 9,7,5, 2,4]
plt.hist(x,bins = 4,color="cyan")
plt.show()

we use Histogram for checking whether it is normal distributed ,
right skewed(positive) or left skewed(negative) .
As a Data scientist, we always want our data to be normal distributed
Now, it all comes into Data visualization which is (science + art) There are various choices one have
various plot types (linear, scatter, histogram, tornado etc) and it's customization
BUT all these choices depends upon
1)  DATA
2)  and the story you want to tell with your data

 Examples of customization, :
Using ticks we can more format the levels
using Numpy package for displaying relational data
Let's play with colors


Comments

Popular Posts