I’m working with a data base that has 20 years of data. I created a function where the aim was to graph the database. The problem that I ran into is that the index of the graph isn’t readable at all.
I tried to use plt.tight_layout() to make the graph readable but it didn’t work. I also tried to write a marker every 300 entries but it also didn’t work.
These are my functions:
def leeDatos():
dataSet = pd.read_csv('covid.csv', header=0, index_col=0)
dataSet.index = pd.to_datetime(dataSet.index,format='%d/%m/%y',errors='ignore')
pd.set_option('display.max_columns', None)
return dataSet
def graficaDatos(dataSet=0):
plt.figure(figsize=(10, 7))
for i in range(len(dataSet.columns)):
plt.plot(dataSet.iloc[:,i],label=dataSet.columns[i],marker=i+2,markevery=1500)
plt.gcf().autofmt_xdate()
plt.title('COVID-19', fontweight='bold')
plt.xlabel('Tiempo')
plt.ylabel('Valor')
plt.legend(loc='upper left')
plt.tight_layout() # Ajusta la disposición para evitar el solapamiento
plt.show()
I tried to run the code both in collab and in vscode to change the enviroment
The Output of the code
frdhz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.