This gallery page showcases histogram-based plots from k-diagram
designed for visualizing the distribution of one-dimensional data,
which is fundamental for evaluating forecast errors and uncertainty.
Note
You need to run the code snippets locally to generate the plot
images referenced below. Ensure the image paths in the
..image:: directives match where you save the plots.
Uses plot_hist_kde() to visualize the
distribution of a variable. It combines a traditional histogram with a
smooth Kernel Density Estimate (KDE) curve to provide a detailed
view of the data’s shape, central tendency, and spread.
1importkdiagram.utils.histaskdh 2importnumpyasnp 3importmatplotlib.pyplotasplt 4 5# --- Data Generation --- 6# Simulate sensor readings with a normal distribution 7np.random.seed(42) 8sensor_readings=np.random.normal(loc=100,scale=15,size=1000) 910# --- Plotting ---11kdh.plot_hist_kde(12sensor_readings,13bins=40,14title="Distribution of Sensor Readings",15x_label="Temperature (°C)",16kde_color="#FF5733",# Custom reddish-orange17# Save the plot (adjust path relative to docs/source/)18savefig="gallery/images/gallery_utils_sensor_reading.png"19)20plt.close()# Close plot after saving