Using hVPlot and the plots won't overlay even though they should, is data frame size an issue?

142 views Asked by At

Unable to create an overlay plot with both curve lines and interact with them both on the same curve. What am I doing wrong? The exp line has more data points than the exp2 line as that was a theoretical line I hard-coded in.

This is my code:

theoreticaly = [20]*420 + [i for i in reversed(np.linspace(-40, 20, 600))]+[-40]*600 + [i for i in np.linspace(-40,40,840)]+[40]*1000
theoreticalx = [i for i in range(0,3460)]

names = {'theoreticalx': theoreticalx, 'theoreticaly': theoreticaly}
part = pd.DataFrame(names)
     
# saving the dataframe to csv
part.to_csv('datatheo.csv', index=False)

#reading in the csv file
readingtheo = pd.read_csv("datatheo.csv")
#Defining the time based on 2895 records and data frequency of 0.4s 
t=[]
for val in df["Time"].tolist():
    nums = re.split(r"[:\s]", val)
    t.append(3600*int(nums[1]) + 60*int(nums[2]) + int(nums[3]) + int(nums[4])/1000)
    time = np.array(t)
    time = time - time[0]
    
avg = [(topt1[j] + topt2[j])/2 for j in range(len(time))]


#make dataframe with both new columns

xcel = {'time': time, 'avg': avg}
final = pd.DataFrame(xcel)
     
# saving the dataframe to csv
final.to_csv('data.csv', index=False)

#reading in the csv file
reading = pd.read_csv("data.csv")

# Plotting the temperatures
exp = reading.hvplot(x='time',y='avg',value_label ='Thermocouple Average',legend = 'right', title = 'Temperature in OTS Top chamber + °C/min',xlabel='Time (s)', ylabel='Temperature (deg C)',line_color ='green')
exp2 = readingtheo.hvplot(x = 'theoreticalx',y = 'theoreticaly',value_label= "Theoretical Pattern Curve",legend = 'right', title = 'Temperature in OTS Top chamber + °C/min',xlabel='Time (s)', ylabel='Temperature (deg C)')
finalplot = (exp+exp2).cols(1)
hvplot.show(finalplot)

The plots just refuse to overlay I tried the holoview option too with .cols(1) it still didn't work.

0

There are 0 answers