Make sure you have Python 3 installed in your system and also below-mentioned modules should be present.
- matplotlib
- numpy
- seaborn
import matplotlib.pyplot as plt import numpy as np import seaborn as sns x = np.array([260.58, 42.21, 88.53, 103.9, 120.23, 215.66, 180.39, 112.66, 637.18, 72.09, 49.23, 67.06, 58.01, 56.26, 104.77, 166.93, 50.87, 51.24, 93.91, 44.54, 61.1, 108.49, 144.94, 88.73, 139.22, 40.18, 53.84, 100.36, 235.53]) '''Same plot PDF and CDF''' plt.rcParams["figure.figsize"] = [12.00, 6.50] plt.rcParams["figure.autolayout"] = True fig,axes=plt.subplots(1,2) sns.kdeplot(x,ax=axes[0],color='green') axes[0].set_title('TITTLE') axes[0].set_ylabel("Y-AXIS TITLE") axes[0].set_xlabel("X-AXIS TITLE") ax = axes[0].lines[0] xs = ax.get_xdata() ys = ax.get_ydata() middle = x.mean() sdev = x.std() left = middle - sdev right = middle + sdev axes[0].vlines(middle, 0, np.interp(middle, xs, ys),ls=':',color='blue') axes[0].fill_between(xs, 0, ys, where=(left <= xs) & (xs <= right), facecolor="red", alpha=0.2) axes[0].fill_between(xs, 0, ys, alpha=0.2, color='yellow') legend_entries = [ 'Curve', f'Mean of X-AXIS DATA: {middle:.2f}ms', f"Standard Deviation of X-AXIS DATA: {sdev:.2f}ms" ] axes[0].legend(legend_entries) sns.ecdfplot(x,ax=axes[1],color='green') axes[1].set_title("TITTLE") axes[1].set_ylabel("Y-AXIS TITLE") axes[1].set_xlabel("X-AXIS TITLE") plt.legend(labels=["Curve",]) plt.show()# if you want to save the image, please comment this line # to save the image #plt.savefig("output3")
Expected output:-
