Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np; np.random.seed(42)
- import pandas as pd
- import matplotlib.pyplot as plt
- Index = [ 1.0, 2.0, 3.0, 4.0, 5.0]
- Cols = [10.0, 20.0, 30.0, 40.0, 50.0]
- df = pd.DataFrame(abs(np.random.randn(5, 5)),
- index=Index, columns=Cols)
- plt.close(1)
- fig,ax = plt.subplots(num=1)
- dx = np.diff(df.columns)[0]/2
- dy = np.diff(df.index)[0]/2
- extent = [df.columns.min()-dx, df.columns.max()+dx,
- df.index.min()-dy, df.index.max()+dy]
- ax.imshow(df, extent=extent, aspect="auto")
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement