Coding/Python

Pandas Built-in Data Visualization 모음

폴밴 2022. 2. 23. 14:41
f = plt.figure()
# select only 0~29 index
df3.iloc[0:30].plot.area(alpha = 0.4, ax = f.gca()) 

# move legend outside of the plot
plt.legend(loc = 'center left', bbox_to_anchor = (1.0, 0.5))  
plt.show()​
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlin inline
df1 = pd.read_csv('df1', index_col=0)
df2 = pd.read_csv('df2')
df1.head()
df2.head()

Style Sheet

df1['A'].hist()

plt.style.use('ggplot')  # use style
df1['A'].hist()

plt.style.use('bmh')
df1['A'].hist()

plt.style.use('dark_background')
df1['A'].hist()

plt.style.use('fivethirtyeight')
df1['A'].hist()


Plot Types

df2.plot.area(alpha = 0.4)
df2.plot.bar(stacked = True)
df1['A'].plot.hist(bins = 30)
df1.plot.line(x = df1.index, y = 'B', figsize = (12,3), lw =1)
# add column value with c
df1.plot.scatter(x = 'A', y = 'B', c = 'C', cmap = 'coolwarm')
# s parameter for size
df1.plot.scatter(x = 'A', y = 'B', s = df1['C'] * 200)  
df2.plot.box()
df = pd.DataFrame(np.random.randn(1000, 2), columns=['a', 'b'])
df.plot.hexbin(x = 'a', y = 'b', gridsize=25, cmap = 'Oranges')

KDE

df2['a'].plot.kde()
df2.plot.density()
df3 =pd.read_csv('df3')
f = plt.figure()

# select only 0~29 index
df3.iloc[0:30].plot.area(alpha = 0.4, ax = f.gca()) 

# move legend outside of the plot
plt.legend(loc = 'center left', bbox_to_anchor = (1.0, 0.5))  

plt.show()

'Coding > Python' 카테고리의 다른 글

Plotly & Cofflinks 라이브러리 모음  (0) 2022.02.25
Seaborn 라이브러리 모음  (0) 2022.02.23
Matplotlib 라이브러리 모음  (0) 2022.02.22
Pandas 라이브러리 모음  (0) 2022.02.21
Numpy 라이브러리 모음  (0) 2022.02.21