Question: I am trying to set the following dates (year only): lab = [1969, 1973, 1977, 1981, 1985, 1989, 1993, 1997, 2001, 2005, 2009, 2013, 2017, 2021, 2025] I tried with dates.YearLocator(base=4), but didn't find a way to set the starting year. I get the labels starting in 1968 instead of 1969. I also tried with ticker.FixedFormatter(lab), but the ticks and dates were shown in the wrong place. # reproducible example import pandas as pd from pandas import Timestamp import numpy as np # np.nan import matplotlib.pyplot as plt from matplotlib import dates from matplotlib import ticker data = {'Date': {1: Timestamp('1969-01-20 00:00:00'), 2: Timestamp('1969-04-01 00:00:00'), 3: Timestamp('1969-07-01 00:00:00'), 4: Timestamp('1969-10-01 00:00:00'), 5: Timestamp('1970-01-01 00:00:00'), 6: Timestamp('1970-04-01 00:00:00'), 7: Timestamp('1970-07-01 00:00:00'), 8: Timestamp('1970-10-01 00:00:00'), 9: Timestamp('1971-01-01 00:00:00'), 10: Timestamp('1971-04-01 00:00:00'), 11: Timestamp('1971-07-01 00:00:00'), 12: Timestamp('1971-10-01 00:00:00'), 13: Timestamp('1972-01-01 00:00:00'), 14: Timestamp('1972-04-01 00:00:00'), 15: Timestamp('1972-07-01 00:00:00'), 16: Timestamp('1972-10-01 00:00:00'), 17: Timestamp('1973-01-01 00:00:00'), 18: Timestamp('1973-04-01 00:00:00'), 19: Timestamp('1973-07-01 00:00:00'), 20: Timestamp('1973-10-01 00:00:00'), 21: Timestamp('1974-01-01 00:00:00'), 22: Timestamp('1974-04-01 00:00:00'), 23: Timestamp('1974-07-01 00:00:00'), 24: Timestamp('1974-08-09 00:00:00'), 25: Timestamp('1974-10-01 00:00:00'), 26: Timestamp('1975-01-01 00:00:00'), 27: Timestamp('1975-04-01 00:00:00'), 28: Timestamp('1975-07-01 00:00:00'), 29: Timestamp('1975-10-01 00:00:00'), 30: Timestamp('1976-01-01 00:00:00'), 31: Timestamp('1976-04-01 00:00:00'), 32: Timestamp('1976-07-01 00:00:00'), 33: Timestamp('1976-10-01 00:00:00'), 34: Timestamp('1977-01-01 00:00:00'), 35: Timestamp('1977-01-20 00:00:00'), 36: Timestamp('1977-04-01 00:00:00'), 37: Timestamp('1977-07-01 00:00:00'), 38: Timestamp('1977-10-01 00:00:00'), 39: Timestamp('1978-01-01 00:00:00'), 40: Timestamp('1978-04-01 00:00:00'), 41: Timestamp('1978-07-01 00:00:00'), 42: Timestamp('1978-10-01 00:00:00'), 43: Timestamp('1979-01-01 00:00:00'), 44: Timestamp('1979-04-01 00:00:00'), 45: Timestamp('1979-07-01 00:00:00'), 46: Timestamp('1979-10-01 00:00:00'), 47: Timestamp('1980-01-01 00:00:00'), 48: Timestamp('1980-04-01 00:00:00'), 49: Timestamp('1980-07-01 00:00:00'), 50: Timestamp('1980-10-01 00:00:00'), 51: Timestamp('1981-01-01 00:00:00'), 52: Timestamp('1981-01-20 00:00:00'), 53: Timestamp('1981-04-01 00:00:00'), 54: Timestamp('1981-07-01 00:00:00'), 55: Timestamp('1981-10-01 00:00:00'), 56: Timestamp('1982-01-01 00:00:00'), 57: Timestamp('1982-04-01 00:00:00'), 58: Timestamp('1982-07-01 00:00:00'), 59: Timestamp('1982-10-01 00:00:00'), 60: Timestamp('1983-01-01 00:00:00'), 61: Timestamp('1983-04-01 00:00:00'), 62: Timestamp('1983-07-01 00:00:00'), 63: Timestamp('1983-10-01 00:00:00'), 64: Timestamp('1984-01-01 00:00:00'), 65: Timestamp('1984-04-01 00:00:00'), 66: Timestamp('1984-07-01 00:00:00'), 67: Timestamp('1984-10-01 00:00:00'), 68: Timestamp('1985-01-01 00:00:00'), 69: Timestamp('1985-04-01 00:00:00'), 70: Timestamp('1985-07-01 00:00:00'), 71: Timestamp('1985-10-01 00:00:00'), 72: Timestamp('1986-01-01 00:00:00'), 73: Timestamp('1986-04-01 00:00:00'), 74: Timestamp('1986-07-01 00:00:00'), 75: Timestamp('1986-10-01 00:00:00'), 76: Timestamp('1987-01-01 00:00:00'), 77: Timestamp('1987-04-01 00:00:00'), 78: Timestamp('1987-07-01 00:00:00'), 79: Timestamp('1987-10-01 00:00:00'), 80: Timestamp('1988-01-01 00:00:00'), 81: Timestamp('1988-04-01 00:00:00'), 82: Timestamp('1988-07-01 00:00:00'), 83: Timestamp('1988-10-01 00:00:00'), 84: Timestamp('1989-01-01 00:00:00'), 85: Timestamp('1989-01-20 00:00:00'), 86: Timestamp('1989-04-01 00:00:00'), 87: Timestamp('1989-07-01 00:00:00'), 88: Timestamp('1989-10-01 00:00:00'), 89: Timestamp('1990-01-01 00:00:00'), 90: Timestamp('1990-04-01 00:00:00'), 91: Timestamp('1990-07-01 00:00:00'), 92: Timestamp('1990-10-01 00:00:00'), 93: Timestamp('1991-01-01 00:00:00'), 94: Timestamp('1991-04-01 00:00:00'), 95: Timestamp('1991-07-01 00:00:00'), 96: Timestamp('1991-10-01 00:00:00'), 97: Timestamp('1992-01-01 00:00:00'), 98: Timestamp('1992-04-01 00:00:00'), 99: Timestamp('1992-07-01 00:00:00'), 100: Timestamp('1992-10-01 00:00:00'), 101: Timestamp('1993-01-01 00:00:00'), 102: Timestamp('1993-01-20 00:00:00'), 103: Timestamp('1993-04-01 00:00:00'), 104: Timestamp('1993-07-01 00:00:00'), 105: Timestamp('1993-10-01 00:00:00'), 106: Timestamp('1994-01-01 00:00:00'), 107: Timestamp('1994-04-01 00:00:00'), 108: Timestamp('1994-07-01 00:00:00'), 109: Timestamp('1994-10-01 00:00:00'), 110: Timestamp('1995-01-01 00:00:00'), 111: Timestamp('1995-04-01 00:00:00'), 112: Timestamp('1995-07-01 00:00:00'), 113: Timestamp('1995-10-01 00:00:00'), 114: Timestamp('1996-01-01 00:00:00'), 115: Timestamp('1996-04-01 00:00:00'), 116: Timestamp('1996-07-01 00:00:00'), 117: Timestamp('1996-10-01 00:00:00'), 118: Timestamp('1997-01-01 00:00:00'), 119: Timestamp('1997-04-01 00:00:00'), 120: Timestamp('1997-07-01 00:00:00'), 121: Timestamp('1997-10-01 00:00:00'), 122: Timestamp('1998-01-01 00:00:00'), 123: Timestamp('1998-04-01 00:00:00'), 124: Timestamp('1998-07-01 00:00:00'), 125: Timestamp('1998-10-01 00:00:00'), 126: Timestamp('1999-01-01 00:00:00'), 127: Timestamp('1999-04-01 00:00:00'), 128: Timestamp('1999-07-01 00:00:00'), 129: Timestamp('1999-10-01 00:00:00'), 130: Timestamp('2000-01-01 00:00:00'), 131: Timestamp('2000-04-01 00:00:00'), 132: Timestamp('2000-07-01 00:00:00'), 133: Timestamp('2000-10-01 00:00:00'), 134: Timestamp('2001-01-01 00:00:00'), 135: Timestamp('2001-01-20 00:00:00'), 136: Timestamp('2001-04-01 00:00:00'), 137: Timestamp('2001-07-01 00:00:00'), 138: Timestamp('2001-10-01 00:00:00'), 139: Timestamp('2002-01-01 00:00:00'), 140: Timestamp('2002-04-01 00:00:00'), 141: Timestamp('2002-07-01 00:00:00'), 142: Timestamp('2002-10-01 00:00:00'), 143: Timestamp('2003-01-01 00:00:00'), 144: Timestamp('2003-04-01 00:00:00'), 145: Timestamp('2003-07-01 00:00:00'), 146: Timestamp('2003-10-01 00:00:00'), 147: Timestamp('2004-01-01 00:00:00'), 148: Timestamp('2004-04-01 00:00:00'), 149: Timestamp('2004-07-01 00:00:00'), 150: Timestamp('2004-10-01 00:00:00'), 151: Timestamp('2005-01-01 00:00:00'), 152: Timestamp('2005-04-01 00:00:00'), 153: Timestamp('2005-07-01 00:00:00'), 154: Timestamp('2005-10-01 00:00:00'), 155: Timestamp('2006-01-01 00:00:00'), 156: Timestamp('2006-04-01 00:00:00'), 157: Timestamp('2006-07-01 00:00:00'), 158: Timestamp('2006-10-01 00:00:00'), 159: Timestamp('2007-01-01 00:00:00'), 160: Timestamp('2007-04-01 00:00:00'), 161: Timestamp('2007-07-01 00:00:00'), 162: Timestamp('2007-10-01 00:00:00'), 163: Timestamp('2008-01-01 00:00:00'), 164: Timestamp('2008-04-01 00:00:00'), 165: Timestamp('2008-07-01 00:00:00'), 166: Timestamp('2008-10-01 00:00:00'), 167: Timestamp('2009-01-01 00:00:00'), 168: Timestamp('2009-01-20 00:00:00'), 169: Timestamp('2009-04-01 00:00:00'), 170: Timestamp('2009-07-01 00:00:00'), 171: Timestamp('2009-10-01 00:00:00'), 172: Timestamp('2010-01-01 00:00:00'), 173: Timestamp('2010-04-01 00:00:00'), 174: Timestamp('2010-07-01 00:00:00'), 175: Timestamp('2010-10-01 00:00:00'), 176: Timestamp('2011-01-01 00:00:00'), 177: Timestamp('2011-04-01 00:00:00'), 178: Timestamp('2011-07-01 00:00:00'), 179: Timestamp('2011-10-01 00:00:00'), 180: Timestamp('2012-01-01 00:00:00'), 181: Timestamp('2012-04-01 00:00:00'), 182: Timestamp('2012-07-01 00:00:00'), 183: Timestamp('2012-10-01 00:00:00'), 184: Timestamp('2013-01-01 00:00:00'), 185: Timestamp('2013-04-01 00:00:00'), 186: Timestamp('2013-07-01 00:00:00'), 187: Timestamp('2013-10-01 00:00:00'), 188: Timestamp('2014-01-01 00:00:00'), 189: Timestamp('2014-04-01 00:00:00'), 190: Timestamp('2014-07-01 00:00:00'), 191: Timestamp('2014-10-01 00:00:00'), 192: Timestamp('2015-01-01 00:00:00'), 193: Timestamp('2015-04-01 00:00:00'), 194: Timestamp('2015-07-01 00:00:00'), 195: Timestamp('2015-10-01 00:00:00'), 196: Timestamp('2016-01-01 00:00:00'), 197: Timestamp('2016-04-01 00:00:00'), 198: Timestamp('2016-07-01 00:00:00'), 199: Timestamp('2016-10-01 00:00:00'), 200: Timestamp('2017-01-01 00:00:00'), 201: Timestamp('2017-01-20 00:00:00'), 202: Timestamp('2017-04-01 00:00:00'), 203: Timestamp('2017-07-01 00:00:00'), 204: Timestamp('2017-10-01 00:00:00'), 205: Timestamp('2018-01-01 00:00:00'), 206: Timestamp('2018-04-01 00:00:00'), 207: Timestamp('2018-07-01 00:00:00'), 208: Timestamp('2018-10-01 00:00:00'), 209: Timestamp('2019-01-01 00:00:00'), 210: Timestamp('2019-04-01 00:00:00'), 211: Timestamp('2019-07-01 00:00:00'), 212: Timestamp('2019-10-01 00:00:00'), 213: Timestamp('2020-01-01 00:00:00'), 214: Timestamp('2020-04-01 00:00:00'), 215: Timestamp('2020-07-01 00:00:00'), 216: Timestamp('2020-10-01 00:00:00'), 217: Timestamp('2021-01-01 00:00:00'), 218: Timestamp('2021-01-20 00:00:00'), 219: Timestamp('2021-04-01 00:00:00'), 220: Timestamp('2021-07-01 00:00:00'), 221: Timestamp('2021-10-01 00:00:00'), 222: Timestamp('2022-01-01 00:00:00'), 223: Timestamp('2022-04-01 00:00:00'), 224: Timestamp('2022-07-01 00:00:00'), 225: Timestamp('2022-10-01 00:00:00'), 226: Timestamp('2023-01-01 00:00:00'), 227: Timestamp('2023-04-01 00:00:00'), 228: Timestamp('2023-07-01 00:00:00'), 229: Timestamp('2023-10-01 00:00:00'), 230: Timestamp('2024-01-01 00:00:00')}, 'Unemployment Rate': {1: 3.4, 2: 3.4, 3: 3.5, 4: 3.7, 5: 3.9, 6: 4.6, 7: 5.0, 8: 5.5, 9: 5.9, 10: 5.9, 11: 6.0, 12: 5.8, 13: 5.8, 14: 5.7, 15: 5.6, 16: 5.6, 17: 4.9, 18: 5.0, 19: 4.8, 20: 4.6, 21: 5.1, 22: 5.1, 23: 5.5, 24: 5.711956521739131, 25: 6.0, 26: 8.1, 27: 8.8, 28: 8.6, 29: 8.4, 30: 7.9, 31: 7.7, 32: 7.8, 33: 7.7, 34: 7.5, 35: 7.4366666666666665, 36: 7.2, 37: 6.9, 38: 6.8, 39: 6.4, 40: 6.1, 41: 6.2, 42: 5.8, 43: 5.9, 44: 5.8, 45: 5.7, 46: 6.0, 47: 6.3, 48: 6.9, 49: 7.8, 50: 7.5, 51: 7.5, 52: 7.4366666666666665, 53: 7.2, 54: 7.2, 55: 7.9, 56: 8.6, 57: 9.3, 58: 9.8, 59: 10.4, 60: 10.4, 61: 10.2, 62: 9.4, 63: 8.8, 64: 8.0, 65: 7.7, 66: 7.5, 67: 7.4, 68: 7.3, 69: 7.3, 70: 7.4, 71: 7.1, 72: 6.7, 73: 7.1, 74: 7.0, 75: 7.0, 76: 6.6, 77: 6.3, 78: 6.1, 79: 6.0, 80: 5.7, 81: 5.4, 82: 5.4, 83: 5.4, 84: 5.4, 85: 5.357777777777778, 86: 5.2, 87: 5.2, 88: 5.3, 89: 5.4, 90: 5.4, 91: 5.5, 92: 5.9, 93: 6.4, 94: 6.7, 95: 6.8, 96: 7.0, 97: 7.3, 98: 7.4, 99: 7.7, 100: 7.3, 101: 7.3, 102: 7.257777777777777, 103: 7.1, 104: 6.9, 105: 6.8, 106: 6.6, 107: 6.4, 108: 6.1, 109: 5.8, 110: 5.6, 111: 5.8, 112: 5.7, 113: 5.5, 114: 5.6, 115: 5.6, 116: 5.5, 117: 5.2, 118: 5.3, 119: 5.1, 120: 4.9, 121: 4.7, 122: 4.6, 123: 4.3, 124: 4.5, 125: 4.5, 126: 4.3, 127: 4.3, 128: 4.3, 129: 4.1, 130: 4.0, 131: 3.8, 132: 4.0, 133: 3.9, 134: 4.2, 135: 4.242222222222223, 136: 4.4, 137: 4.6, 138: 5.3, 139: 5.7, 140: 5.9, 141: 5.8, 142: 5.7, 143: 5.8, 144: 6.0, 145: 6.2, 146: 6.0, 147: 5.7, 148: 5.6, 149: 5.5, 150: 5.5, 151: 5.3, 152: 5.2, 153: 5.0, 154: 5.0, 155: 4.7, 156: 4.7, 157: 4.7, 158: 4.4, 159: 4.6, 160: 4.5, 161: 4.7, 162: 4.7, 163: 5.0, 164: 5.0, 165: 5.8, 166: 6.5, 167: 7.8, 168: 8.053333333333333, 169: 9.0, 170: 9.5, 171: 10.0, 172: 9.8, 173: 9.9, 174: 9.4, 175: 9.4, 176: 9.1, 177: 9.1, 178: 9.0, 179: 8.8, 180: 8.3, 181: 8.2, 182: 8.2, 183: 7.8, 184: 8.0, 185: 7.6, 186: 7.3, 187: 7.2, 188: 6.6, 189: 6.2, 190: 6.2, 191: 5.7, 192: 5.7, 193: 5.4, 194: 5.2, 195: 5.0, 196: 4.8, 197: 5.1, 198: 4.8, 199: 4.9, 200: 4.7, 201: 4.636666666666667, 202: 4.4, 203: 4.3, 204: 4.2, 205: 4.0, 206: 4.0, 207: 3.8, 208: 3.8, 209: 4.0, 210: 3.7, 211: 3.7, 212: 3.6, 213: 3.6, 214: 14.8, 215: 10.2, 216: 6.8, 217: 6.4, 218: 6.336666666666667, 219: 6.1, 220: 5.4, 221: 4.5, 222: 4.0, 223: 3.7, 224: 3.5, 225: 3.6, 226: 3.4, 227: 3.4, 228: 3.5, 229: 3.8, 230: 3.7}, 'Republican': {1: True, 2: True, 3: True, 4: True, 5: True, 6: True, 7: True, 8: True, 9: True, 10: True, 11: True, 12: True, 13: True, 14: True, 15: True, 16: True, 17: True, 18: True, 19: True, 20: True, 21: True, 22: True, 23: True, 24: True, 25: True, 26: True, 27: True, 28: True, 29: True, 30: True, 31: True, 32: True, 33: True, 34: True, 35: False, 36: False, 37: False, 38: False, 39: False, 40: False, 41: False, 42: False, 43: False, 44: False, 45: False, 46: False, 47: False, 48: False, 49: False, 50: False, 51: False, 52: True, 53: True, 54: True, 55: True, 56: True, 57: True, 58: True, 59: True, 60: True, 61: True, 62: True, 63: True, 64: True, 65: True, 66: True, 67: True, 68: True, 69: True, 70: True, 71: True, 72: True, 73: True, 74: True, 75: True, 76: True, 77: True, 78: True, 79: True, 80: True, 81: True, 82: True, 83: True, 84: True, 85: True, 86: True, 87: True, 88: True, 89: True, 90: True, 91: True, 92: True, 93: True, 94: True, 95: True, 96: True, 97: True, 98: True, 99: True, 100: True, 101: True, 102: False, 103: False, 104: False, 105: False, 106: False, 107: False, 108: False, 109: False, 110: False, 111: False, 112: False, 113: False, 114: False, 115: False, 116: False, 117: False, 118: False, 119: False, 120: False, 121: False, 122: False, 123: False, 124: False, 125: False, 126: False, 127: False, 128: False, 129: False, 130: False, 131: False, 132: False, 133: False, 134: False, 135: True, 136: True, 137: True, 138: True, 139: True, 140: True, 141: True, 142: True, 143: True, 144: True, 145: True, 146: True, 147: True, 148: True, 149: True, 150: True, 151: True, 152: True, 153: True, 154: True, 155: True, 156: True, 157: True, 158: True, 159: True, 160: True, 161: True, 162: True, 163: True, 164: True, 165: True, 166: True, 167: True, 168: False, 169: False, 170: False, 171: False, 172: False, 173: False, 174: False, 175: False, 176: False, 177: False, 178: False, 179: False, 180: False, 181: False, 182: False, 183: False, 184: False, 185: False, 186: False, 187: False, 188: False, 189: False, 190: False, 191: False, 192: False, 193: False, 194: False, 195: False, 196: False, 197: False, 198: False, 199: False, 200: False, 201: True, 202: True, 203: True, 204: True, 205: True, 206: True, 207: True, 208: True, 209: True, 210: True, 211: True, 212: True, 213: True, 214: True, 215: True, 216: True, 217: True, 218: False, 219: False, 220: False, 221: False, 222: False, 223: False, 224: False, 225: False, 226: False, 227: False, 228: False, 229: False, 230: False}, 'Democrat': {1: False, 2: False, 3: False, 4: False, 5: False, 6: False, 7: False, 8: False, 9: False, 10: False, 11: False, 12: False, 13: False, 14: False, 15: False, 16: False, 17: False, 18: False, 19: False, 20: False, 21: False, 22: False, 23: False, 24: False, 25: False, 26: False, 27: False, 28: False, 29: False, 30: False, 31: False, 32: False, 33: False, 34: False, 35: True, 36: True, 37: True, 38: True, 39: True, 40: True, 41: True, 42: True, 43: True, 44: True, 45: True, 46: True, 47: True, 48: True, 49: True, 50: True, 51: True, 52: False, 53: False, 54: False, 55: False, 56: False, 57: False, 58: False, 59: False, 60: False, 61: False, 62: False, 63: False, 64: False, 65: False, 66: False, 67: False, 68: False, 69: False, 70: False, 71: False, 72: False, 73: False, 74: False, 75: False, 76: False, 77: False, 78: False, 79: False, 80: False, 81: False, 82: False, 83: False, 84: False, 85: False, 86: False, 87: False, 88: False, 89: False, 90: False, 91: False, 92: False, 93: False, 94: False, 95: False, 96: False, 97: False, 98: False, 99: False, 100: False, 101: False, 102: True, 103: True, 104: True, 105: True, 106: True, 107: True, 108: True, 109: True, 110: True, 111: True, 112: True, 113: True, 114: True, 115: True, 116: True, 117: True, 118: True, 119: True, 120: True, 121: True, 122: True, 123: True, 124: True, 125: True, 126: True, 127: True, 128: True, 129: True, 130: True, 131: True, 132: True, 133: True, 134: True, 135: False, 136: False, 137: False, 138: False, 139: False, 140: False, 141: False, 142: False, 143: False, 144: False, 145: False, 146: False, 147: False, 148: False, 149: False, 150: False, 151: False, 152: False, 153: False, 154: False, 155: False, 156: False, 157: False, 158: False, 159: False, 160: False, 161: False, 162: False, 163: False, 164: False, 165: False, 166: False, 167: False, 168: True, 169: True, 170: True, 171: True, 172: True, 173: True, 174: True, 175: True, 176: True, 177: True, 178: True, 179: True, 180: True, 181: True, 182: True, 183: True, 184: True, 185: True, 186: True, 187: True, 188: True, 189: True, 190: True, 191: True, 192: True, 193: True, 194: True, 195: True, 196: True, 197: True, 198: True, 199: True, 200: True, 201: False, 202: False, 203: False, 204: False, 205: False, 206: False, 207: False, 208: False, 209: False, 210: False, 211: False, 212: False, 213: False, 214: False, 215: False, 216: False, 217: False, 218: True, 219: True, 220: True, 221: True, 222: True, 223: True, 224: True, 225: True, 226: True, 227: True, 228: True, 229: True, 230: True}, 'President': {1: 'Nixon', 2: 'Nixon', 3: 'Nixon', 4: 'Nixon', 5: 'Nixon', 6: 'Nixon', 7: 'Nixon', 8: 'Nixon', 9: 'Nixon', 10: 'Nixon', 11: 'Nixon', 12: 'Nixon', 13: 'Nixon', 14: 'Nixon', 15: 'Nixon', 16: 'Nixon', 17: 'Nixon', 18: 'Nixon', 19: 'Nixon', 20: 'Nixon', 21: 'Nixon', 22: 'Nixon', 23: 'Nixon', 24: 'Ford', 25: 'Ford', 26: 'Ford', 27: 'Ford', 28: 'Ford', 29: 'Ford', 30: 'Ford', 31: 'Ford', 32: 'Ford', 33: 'Ford', 34: 'Ford', 35: 'Carter', 36: 'Carter', 37: 'Carter', 38: 'Carter', 39: 'Carter', 40: 'Carter', 41: 'Carter', 42: 'Carter', 43: 'Carter', 44: 'Carter', 45: 'Carter', 46: 'Carter', 47: 'Carter', 48: 'Carter', 49: 'Carter', 50: 'Carter', 51: 'Carter', 52: 'Reagan', 53: 'Reagan', 54: 'Reagan', 55: 'Reagan', 56: 'Reagan', 57: 'Reagan', 58: 'Reagan', 59: 'Reagan', 60: 'Reagan', 61: 'Reagan', 62: 'Reagan', 63: 'Reagan', 64: 'Reagan', 65: 'Reagan', 66: 'Reagan', 67: 'Reagan', 68: 'Reagan', 69: 'Reagan', 70: 'Reagan', 71: 'Reagan', 72: 'Reagan', 73: 'Reagan', 74: 'Reagan', 75: 'Reagan', 76: 'Reagan', 77: 'Reagan', 78: 'Reagan', 79: 'Reagan', 80: 'Reagan', 81: 'Reagan', 82: 'Reagan', 83: 'Reagan', 84: 'Reagan', 85: 'Bush', 86: 'Bush', 87: 'Bush', 88: 'Bush', 89: 'Bush', 90: 'Bush', 91: 'Bush', 92: 'Bush', 93: 'Bush', 94: 'Bush', 95: 'Bush', 96: 'Bush', 97: 'Bush', 98: 'Bush', 99: 'Bush', 100: 'Bush', 101: 'Bush', 102: 'Clinton', 103: 'Clinton', 104: 'Clinton', 105: 'Clinton', 106: 'Clinton', 107: 'Clinton', 108: 'Clinton', 109: 'Clinton', 110: 'Clinton', 111: 'Clinton', 112: 'Clinton', 113: 'Clinton', 114: 'Clinton', 115: 'Clinton', 116: 'Clinton', 117: 'Clinton', 118: 'Clinton', 119: 'Clinton', 120: 'Clinton', 121: 'Clinton', 122: 'Clinton', 123: 'Clinton', 124: 'Clinton', 125: 'Clinton', 126: 'Clinton', 127: 'Clinton', 128: 'Clinton', 129: 'Clinton', 130: 'Clinton', 131: 'Clinton', 132: 'Clinton', 133: 'Clinton', 134: 'Clinton', 135: 'Bush', 136: 'Bush', 137: 'Bush', 138: 'Bush', 139: 'Bush', 140: 'Bush', 141: 'Bush', 142: 'Bush', 143: 'Bush', 144: 'Bush', 145: 'Bush', 146: 'Bush', 147: 'Bush', 148: 'Bush', 149: 'Bush', 150: 'Bush', 151: 'Bush', 152: 'Bush', 153: 'Bush', 154: 'Bush', 155: 'Bush', 156: 'Bush', 157: 'Bush', 158: 'Bush', 159: 'Bush', 160: 'Bush', 161: 'Bush', 162: 'Bush', 163: 'Bush', 164: 'Bush', 165: 'Bush', 166: 'Bush', 167: 'Bush', 168: 'Obama', 169: 'Obama', 170: 'Obama', 171: 'Obama', 172: 'Obama', 173: 'Obama', 174: 'Obama', 175: 'Obama', 176: 'Obama', 177: 'Obama', 178: 'Obama', 179: 'Obama', 180: 'Obama', 181: 'Obama', 182: 'Obama', 183: 'Obama', 184: 'Obama', 185: 'Obama', 186: 'Obama', 187: 'Obama', 188: 'Obama', 189: 'Obama', 190: 'Obama', 191: 'Obama', 192: 'Obama', 193: 'Obama', 194: 'Obama', 195: 'Obama', 196: 'Obama', 197: 'Obama', 198: 'Obama', 199: 'Obama', 200: 'Obama', 201: 'Trump', 202: 'Trump', 203: 'Trump', 204: 'Trump', 205: 'Trump', 206: 'Trump', 207: 'Trump', 208: 'Trump', 209: 'Trump', 210: 'Trump', 211: 'Trump', 212: 'Trump', 213: 'Trump', 214: 'Trump', 215: 'Trump', 216: 'Trump', 217: 'Trump', 218: 'Biden', 219: 'Biden', 220: 'Biden', 221: 'Biden', 222: 'Biden', 223: 'Biden', 224: 'Biden', 225: 'Biden', 226: 'Biden', 227: 'Biden', 228: 'Biden', 229: 'Biden', 230: 'Biden'}} df = pd.DataFrame.from_dict(data) # set up plot f, ax = plt.subplots(figsize=(12, 8)) df.plot(ax=ax, x="Date", y="Unemployment Rate",color="darkgreen", zorder=2, legend=False)# legend=False is ignored y1, y2 = ax.get_ylim() ax.fill_between(df["Date"], y1=y1, y2=y2, where=df["Republican"], color="#E81B23", alpha=0.5, zorder=1, label="Rebublican") ax.fill_between(df["Date"], y1=y1, y2=y2, where=df["Democrat"], color="#00AEF3", alpha=0.5, zorder=1, label="Democrat") # set labels on every 4th years at selected dates | attempt 1 ax.xaxis.set_major_locator(dates.YearLocator(base=4)) # set labels on every 4th years at selected dates | attempt 2 #lab = list(range(1969,2026,4)) #ax.xaxis.set_major_formatter(ticker.FixedFormatter(lab)) ax.figure.autofmt_xdate(rotation=0, ha="center") ax.set_xlabel('') ax.set_ylabel('Unemployment Rate (%)') ax.set_title("U.S. Unemployment Rate") # set legend ax.legend()# I do want to keep the filled area legends # position the legend ax.legend(bbox_to_anchor=(0.8, 1.08), loc="center") # set grid ax.grid(True) f.tight_layout()# not as tight as I would like plt.show()   P.S. Unrelated things I'd like to do: remove the white space outside of the blue/red filled areas; remove the "Unemployment Rate" from the legend (while keeping Republican/Democrat).

Answer: You can directly set the x-ticks you want with a list of datetimes: lab = [1969, 1973, 1977, 1981, 1985, 1989, 1993, 1997, 2001, 2005, 2009, 2013, 2017, 2021, 2025] lab_dates = [datetime.date(year, 1, 1) for year in lab] ax.xaxis.set_ticks(lab_dates)  that overrides the formatting so that the labels show up like "1973-1-1", but we can reinstate the simple year formatting with ax.xaxis.set_major_formatter(dates.DateFormatter('%Y'))  The white space around the blue/red filled areas is the margins. I found that if I set that to zero, the "1969" tick didn't show up, but it's fine if I set it to something very small: ax.margins(0.001)