histoprint is a Python library that provides pretty-printing of NumPy (and other compatible) histograms directly to the console. It leverages terminal color codes and Unicode characters to create visually appealing histogram representations. Currently at version 2.6.0, it follows a regular release cadence with updates typically adding features, improving compatibility, and addressing minor issues.
pip install histoprintVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to generate sample data using NumPy and then visualize it as histograms in the console using `histoprint.text_hist` for single-array input and `histoprint.print_hist` for displaying multiple or pre-computed NumPy histograms, including stacked visualizations.
Upgrade your Python environment to 3.8 or later.
Change install command from `histoprint[root]` to `histoprint[uproot]`.
Ensure your Python environment is version 3.8 or higher.
Consult histoprint documentation for options to disable or limit Unicode combining characters, such as `symbols` argument in `print_hist` or specific configuration settings if available.
Always pass pre-computed histogram data (counts and bin edges) to `print_hist` or ensure the object adheres to the `PlottableProtocol`.
To fix this, you can instruct histoprint to use a simpler set of symbols or disable colors. For example, pass `symbols='|= '` to `print_hist` or `text_hist` to avoid combining characters, or adjust your terminal's font or settings if it supports better Unicode rendering.
Add the import statement `from histoprint import text_hist` (or `from histoprint import print_hist` for `print_hist`) at the beginning of your Python script or interactive session.
First, compute the histogram using `numpy.histogram()` with your data and desired bins, then pass the resulting tuple to `histoprint.print_hist()` or `histoprint.text_hist()`. For example: `hist_data = np.histogram(my_data, bins=10); histoprint.print_hist(hist_data)`.
Use the correct functions provided by `histoprint` for printing histograms, which are `histoprint.text_hist()` for simple histograms or `histoprint.print_hist()` for more advanced options, including multiple histograms and overlays.