这是我用来生成以下输出的代码:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
xedges = [27.5, 35, 42.5, 50, 57.5, 65, 72.5, 80, 87.5, 95, 102.5, 110, 117.5, 125, 132.5, 140, 147.5, 155, 162.5]
yedges = [0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380]
H = pd.read_stata ('R:/data.dta')
fig = plt.figure()
plt.imshow(H, cmap="nipy_spectral", interpolation='bilinear', origin='low',extent=[xedges[0], xedges[-1], yedges[0], yedges[-1]])
图表上的x轴看起来非常压缩。我想能够产生相同的图表,但具有更大的X轴,我怎么能做到这一点?
我怀疑这与“extent”参数有关,但我不确定如何做。