Suppose you do this with a jupyter notebook.
If you do it on the terminal, you need to save the graph to a file. To save it, use plt.savefig ("filename ")
.
#Library used for numerical calculation
import numpy as np
import pandas as pd
#Library for drawing graphs
from matplotlib import pyplot as plt
#Specification to display the graph in jupyter Notebook
%matplotlib inline
x = np.array([0,1,2,3,4,5,6,7,8,9])
y = np.array([2,3,4,3,5,4,6,7,4,8])
plt.plot(x, y, color = 'black')
plt.title("lineplot matplotlib")
plt.xlabel("x")
plt.ylabel("y")
import seaborn as sns
sns.set()
plt.plot(x, y, color = 'black')
plt.title("lineplot seaborn")
plt.xlabel("x")
plt.ylabel("y")
data = np.array([2,3,3,4,4,4,4,5,5,6])
sns.distplot(data, bins = 5,
color = 'black', kde = False)
<img width="300" height ="200"alt="hist.png " src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512772/0c701442-e3c8-4214-8968-05731fb6c8b9.png ">
--Define how many groups the data should be divided into with bins. --Set the display / non-display of kernel density estimation [^ 1] with kde
[^ 1]: One of the nonparametric methods for estimating the probability density function of random variables in statistics.
sns.distplot(fish_data, color = 'black' norm_hist=True)
--`norm_hist` changes the vertical axis so that the total area of the histogram is 1.
sns.boxplot(x = "species", y = "length",
data = multi, color = 'gray')
Using the result of kernel density estimation
sns.violinplot(x = "species", y = "length",
data = multi, color = 'gray')
sns.barplot(x = "species", y = "length",
data = fish_multi, color = 'gray')
sns.jointplot(x = "x", y = "y",
data = cov_data, color = 'black')
sns.lmplot(x = "temperature", y = "beer", data = D,
scatter_kws = {"color": "black"},
line_kws = {"color": "black"})
sns.lmplot(x = "price", y = "sales", data = sales,
hue = "weather", palette = "gray")
Shinya Baba, a textbook on statistics learned with new Python
Recommended Posts