Skip to content Skip to sidebar Skip to footer

How To Make Overlay Plots Of A Variable, But Every Plot Than I Want To Make Has A Different Length Of Data

I want to overlay 30 plots, each of those is the Temperature of one day, to make at the end a comparison of the develop of the Temperature and how much differ from one day to anoth

Solution 1:

if I understood your question right, that you want to plot all days in a single plot, you have togenerate one figure, plt.plot() all days before you finally plt.show() the image including all plots made before. Try something like shown below:

(as I don't know your data, I don't know if this code would work. the concept should be clear at least.)

import pandas as pd
from datetime import date
import datetime as dt
import calendar
import numpy as np
import pylab as plt 
import matplotlib.ticker as ticker
import seaborn as sns
>
datos = pd.read_csv("Jun2018T.txt", sep = ',', names=('Fecha', 'Hora', 'RADNETA', 'RADCORENT', 'RADCORSAL', 'RADINFENT', 'RADINFSAL', 'TEMP'))
>
datos['Hora'] = datos['Hora'].str[:9]

>

imagen = plt.figure(figsize=(25,10))

for day inrange(1,31):
    dia = datos[datos['Fecha'] == "2018-06-"+(f"{day:02d}")]
    tiempo= pd.to_datetime(dia['HORA'], format='%H:%M:%S').dt.time
    temp= dia['TEMP']
    plt.plot(tiempo, temp)

#plt.xticks(np.arange(0, 54977, 7000)) 
plt.xlabel("Tiempo (H:M:S)(Formato 24 Horas)")
plt.ylabel("Temperatura (K)")
plt.title("Jun 2018")
plt.show()
imagen.savefig('JUN2018')

For the second part of your question: as your data is stored with an timestamp, you can transform it to pandas time objects. Using them for plots, the x-axis should not have an offset anymore. I've modified the tiempo =... assignment in the code above.

The x-tics should automatically be in time mode now.

Post a Comment for "How To Make Overlay Plots Of A Variable, But Every Plot Than I Want To Make Has A Different Length Of Data"