对于以下Matplotlib图,我想:
这是我的代码:
import pandas as pd
import numpy as np
ONE_YEAR_IN_DAYS = 365
ONE_DAY_IN_TIMESTAMP_UNITS = 86400000000000
import pandas as pd
start = pd.Timestamp('2016-07-01')
end = pd.Timestamp('2017-07-01')
t = np.linspace(start.value, end.value, 100 * ONE_YEAR_IN_DAYS)
sinus = np.sin(2 * np.pi * 1 * t / ONE_DAY_IN_TIMESTAMP_UNITS)
t = end.value - t
import matplotlib
matplotlib.use('TkAgg')
font = {'family': 'normal',
'size': 8}
matplotlib.rc('font', **font)
import matplotlib.pyplot as plt
axes = plt.gca()
import matplotlib.ticker as ticker
plt.rcParams["figure.dpi"] = 400
plt.xticks(rotation=90)
plt.minorticks_on()
plt.grid()
from matplotlib.ticker import FormatStrFormatter
from matplotlib.ticker import LogFormatter
plt.minorticks_on()
formatter = LogFormatter(labelOnlyBase=True, )
plt.setp(axes.xaxis.get_minorticklabels(), rotation=90)
locmaj = matplotlib.ticker.LogLocator(base=5.0,numticks=12)
axes.xaxis.set_major_locator(locmaj)
locmin = matplotlib.ticker.LogLocator(base=5.0,subs=(0.2,0.4,0.6,0.8),numticks=12)
axes.xaxis.set_minor_locator(locmin)
axes.xaxis.set_minor_formatter(matplotlib.ticker.NullFormatter())
plt.semilogx(t, sinus, "-o", markersize=2)
plt.show()
我使用Matplotlib 2.0.2。
如您所见,我在正确的次要标签生成方面有些挣扎。
这是我得到的当前结果: