Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import numpy as np; np.random.seed(42)
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4.  
  5. Index = [ 1.0, 2.0, 3.0, 4.0, 5.0]
  6. Cols = [10.0, 20.0, 30.0, 40.0, 50.0]
  7. df = pd.DataFrame(abs(np.random.randn(5, 5)),
  8. index=Index, columns=Cols)
  9. plt.close(1)
  10. fig,ax = plt.subplots(num=1)
  11. dx = np.diff(df.columns)[0]/2
  12. dy = np.diff(df.index)[0]/2
  13. extent = [df.columns.min()-dx, df.columns.max()+dx,
  14. df.index.min()-dy, df.index.max()+dy]
  15. ax.imshow(df, extent=extent, aspect="auto")
  16.  
  17. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement