Pandas及Seanborn绘图
1.Pandas绘图
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib notebook
plt.style.use('seaborn-colorblind')
DataFrame绘图
df=pd.DataFrame({'A':np.random.randn(365).cumsum(0),
'B':np.random.randn(365).cumsum(0)-20,
'C':np.random.randn(365).cumsum(0)+20},
index=pd.date_range('2017/1/1',periods=365)
)
df.head()
| A | B | C |
---|
2017-01-01 | -1.698398 | -20.924948 | 20.212802 |
---|
2017-01-02 | -2.435280 | -19.829875 | 20.926675 |
---|
2017-01-03 | -2.562967 | -19.745036 | 21.485979 |
---|
2017-01-04 | -3.389562 | -19.060533 | 21.424233 |
---|
2017-01-05 | -2.279047 | -19.132374 | 21.485540 |
---|
df.plot()
<IPython.core.display.Javascript object>
<matplotlib.axes._subplots.AxesSubplot at 0x1ea18b50d90>
df.plot('A','B',kind='scatter')
<IPython.core.display.Javascript object>
<matplotlib.axes._subplots.AxesSubplot at 0x1ea18f2bc70>
ax=df.plot('A','C',kind='scatter',
c='B',s=df['B'],colormap='viridis')
<IPython.core.display.Javascript object>
c:\users\asus\appdata\local\programs\python\python38\lib\site-packages\matplotlib\collections.py:857: RuntimeWarning: invalid value encountered in sqrt
scale = np.sqrt(self._sizes) * dpi / 72.0 * self._factor
ax.set_aspect('equal')
df.plot(kind='box')
<IPython.core.display.Javascript object>