/ Python And R Data science skills: 79 special plots

Sunday 18 February 2018

79 special plots

https://vlrtraining.com/courses/python-data-science-beginner-tutorial 79 special plots
In [30]:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 5, 11)
y = x ** 2 
%matplotlib inline
In [31]:
plt.scatter(x,y)
Out[31]:
<matplotlib.collections.PathCollection at 0xa7a9860>
In [5]:
from random import sample
data = sample(range(1, 1000), 100)
#plt.hist(data)
data
Out[5]:
[280,
 594,
 816,
 225,
 119,
 709,
 572,
 614,
 765,
 653,
 452,
 319,
 168,
 579,
 242,
 630,
 351,
 507,
 865,
 459,
 868,
 145,
 208,
 536,
 267,
 205,
 513,
 352,
 87,
 895,
 564,
 742,
 472,
 622,
 738,
 856,
 464,
 375,
 404,
 833,
 427,
 553,
 503,
 343,
 700,
 256,
 383,
 438,
 878,
 212,
 953,
 974,
 131,
 692,
 189,
 49,
 405,
 295,
 155,
 861,
 770,
 839,
 21,
 949,
 447,
 511,
 81,
 613,
 449,
 483,
 988,
 92,
 766,
 944,
 684,
 228,
 525,
 661,
 342,
 366,
 575,
 162,
 825,
 308,
 156,
 851,
 790,
 485,
 645,
 213,
 919,
 1,
 328,
 907,
 368,
 247,
 758,
 434,
 126,
 841]
In [21]:
from random import sample
data = sample(range(1, 1000), 100)
plt.hist(data)
Out[21]:
(array([ 11.,   9.,   8.,  11.,  13.,  13.,  11.,   9.,   9.,   6.]),
 array([   5. ,  104.2,  203.4,  302.6,  401.8,  501. ,  600.2,  699.4,
         798.6,  897.8,  997. ]),
 <a list of 10 Patch objects>)
In [23]:
z=[10,20,30,40,50]

plt.hist(z)
Out[23]:
(array([ 1.,  0.,  1.,  0.,  0.,  1.,  0.,  1.,  0.,  1.]),
 array([ 10.,  14.,  18.,  22.,  26.,  30.,  34.,  38.,  42.,  46.,  50.]),
 <a list of 10 Patch objects>)
In [32]:
z=[10,20,30,40,50,20,10,30,30]

plt.hist(z)
Out[32]:
(array([ 2.,  0.,  2.,  0.,  0.,  3.,  0.,  1.,  0.,  1.]),
 array([ 10.,  14.,  18.,  22.,  26.,  30.,  34.,  38.,  42.,  46.,  50.]),
 <a list of 10 Patch objects>)
In [33]:
data = [np.random.normal(0, std, 100) for std in range(1, 4)]
#data
# rectangular box plot
plt.boxplot(data,vert=True,patch_artist=True);   

No comments:

Post a Comment