我有幾個時間數(shù)據(jù)圖如下:比如這個時間系列從 2003.01 開始,到 2007.01 結束。我不知道為什么 matplotlib 決定將 xticks 放在一些不太方便閱讀時間序列的隨機位置。我希望在時間序列開始時有一個 xtick,然后在每年年初有另一個 xtick。我不能使用“xlim”技巧,因為我有大約 1000 個不同的圖。這是我目前使用的代碼matplotlib.rcParams['text.latex.preamble']=[r"\usepackage{amsmath}"]plt.style.use('fivethirtyeight')def to_inch(cm): return cm/2.54 rc('figure', **{ "facecolor": "white", "figsize": (to_inch(11.7), to_inch(8.27),)})rc('text', usetex=False)font = { 'family': 'serif', 'serif': ['Computer Modern'], 'size': 8}rc('font', **font)labelsize = 6linewidth = 0.5axes = { 'labelsize': labelsize, "edgecolor": '#cbcbcb', "linewidth": linewidth, "facecolor": "white"}rc("grid", **{"linewidth": linewidth}) rc('axes', **axes)rc('legend', **{'fontsize': 5})rc('xtick', **{"labelsize": labelsize})rc('ytick', **{"labelsize": labelsize})nc = Dataset("o_gg.nc", 'r+')#Get timetime = num2date(nc.variables['time'[:],getattr(nc.variables['time'],'units'))time_ctr_ch = np.array([ xx-dt.timedelta(hours=12,minutes=15) for xx in time])ctr_chtessel_soil = nc.variables['SoilMoist'][:,:,0,0]plt.plot(time_ctr_ch, ctr_chtessel_soil, c='lightsteelblue', linewidth=0.5
添加回答
舉報
0/150
提交
取消