|
| 1 | +import pandas as pd |
| 2 | +import numpy as np |
| 3 | +import matplotlib.pyplot as plt |
| 4 | + |
| 5 | +def craw_bar(): |
| 6 | + df2 = pd.DataFrame(np.random.rand(10, 4), columns=['a', 'b', 'c', 'd']) |
| 7 | + df2.plot.bar() |
| 8 | + plt.show() |
| 9 | + |
| 10 | +def craw_line(): |
| 11 | + ts = pd.Series(np.random.randn(1000), index=pd.date_range("1/1/2000", periods=1000)) |
| 12 | + ts = ts.cumsum() |
| 13 | + ts.plot() |
| 14 | + plt.show() |
| 15 | + |
| 16 | +def craw_line1(): |
| 17 | + ts = pd.Series(np.random.randn(1000), index=pd.date_range("1/1/2000", periods=1000)) |
| 18 | + df = pd.DataFrame(np.random.randn(1000, 4), index=ts.index, columns=list("ABCD")) |
| 19 | + df = df.cumsum() |
| 20 | + df.plot() |
| 21 | + plt.show() |
| 22 | + |
| 23 | + |
| 24 | +def craw_bar(): |
| 25 | + ts = pd.Series(np.random.randn(1000), index=pd.date_range("1/1/2000", periods=1000)) |
| 26 | + df = pd.DataFrame(np.random.randn(1000, 4), index=ts.index, columns=list("ABCD")) |
| 27 | + plt.figure() |
| 28 | + df.iloc[5].plot(kind="bar") |
| 29 | + plt.show() |
| 30 | + |
| 31 | +def craw_bar1(): |
| 32 | + df2 = pd.DataFrame(np.random.rand(10, 4), columns=["a", "b", "c", "d"]) |
| 33 | + df2.plot.bar() |
| 34 | + plt.show() |
| 35 | + |
| 36 | +def craw_bar2(): |
| 37 | + df2 = pd.DataFrame(np.random.rand(10, 4), columns=["a", "b", "c", "d"]) |
| 38 | + df2.plot.bar(stacked=True) |
| 39 | + plt.show() |
| 40 | + |
| 41 | +def craw_bar3(): |
| 42 | + df2 = pd.DataFrame(np.random.rand(10, 4), columns=["a", "b", "c", "d"]) |
| 43 | + df2.plot.barh(stacked=True) |
| 44 | + plt.show() |
| 45 | + |
| 46 | +if __name__ == '__main__': |
| 47 | + craw_bar3() |
0 commit comments