我有一个这样的图:
ax.xaxis.set_major_locator(matplotlib.dates.YearLocator())
ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%Y'))
但是现在我有很多年了,我只想在x轴上使用几十年:1970 1980 1990 2000,依此类推。我该如何实现?
答案 0 :(得分:1)
https://matplotlib.org/api/dates_api.html#matplotlib.dates.YearLocator
ax.xaxis.set_major_locator(matplotlib.dates.YearLocator(10))
答案 1 :(得分:0)
您可以显式设置x标记:
public static class SettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.root_preferences, rootKey);
((SeekBarPreference) findPreference(R.id.seekRounds)).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final int progress = Integer.valueOf(String.valueOf(newValue));
preference.setSummary(String.format("Current value: %d", progress));
}
});
}