How do I set the plot chart x-axis name?

Asked 2 years ago, Updated 2 years ago, 55 views

I'd like to put this name on the x-axis of 2018 2019 2020 2021 2022 and show it as a plot. How do I type the code to keep the 20180, 5 and 2019 values from coming up?

python matplotlib

2022-09-20 11:31

1 Answers

import matplotlib.pyplot as plt
from matplotlib import dates

plt.figure()
ax = plt.gca()
ax.xaxis.set_major_locator(dates.YearLocator())

You can add it.


2022-09-20 11:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.