I have this code
df1 = df['T1'].values
df1 = df1 [~np.isnan(df1 )].tolist()
plt.hist(df1 , bins='auto', range=(0,100))
plt.show()
Which gives me this graph
and this code
df2 = df['T2'].values
df2 = df2 [~np.isnan(df2 )].tolist()
plt.hist(df2 , bins='auto', range=(0,100))
plt.show()
which gives me this
Is there any way I can convert Histograms to Curves and then combine them together?
Something like this
You can use np.histogram
:
import numpy as np
from matplotlib import pyplot as plt
fig, ax = plt.subplots()
chisq = np.random.chisquare(3, 1000)
norm = np.random.normal(10, 4, 1000)
chisq_counts, chisq_bins = np.histogram(chisq, 50)
norm_counts, norm_bins = np.histogram(norm, 50)
ax.plot(chisq_bins[:-1], chisq_counts)
ax.plot(norm_bins[:-1], norm_counts)
plt.show()
In the specific case of your data, which has outliers, we will need to clip it before plotting:
clipped_df1 = np.clip(df1, 0, 100)
clipped_df2 = np.clip(df2, 0, 100)
# continue plotting
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.