Skip to main content

No project description provided

Project description

Easy Histogram

This is a very small python package used to make histograms in python, and optionally plot them with matplotlib. The underlying histogramming tool is from numpy. This provides a very handy wrappers around them to easily make common histograms in 1d and 2d and plot with nice labels.

Installation

$ pip install easyhist

Usage

You can import the library and make histograms and plot them(optionally)

import numpy as np
import matplotlib.pyplot as plt
import easyhist as eh


# initialize data
x = np.random.normal(0,1,10000)
h = eh.Hist1D(x,bins='auto')

The returned histogram object has a handy plot method which uses matplotlib to plot the histogram.

fig,ax = plt.subplots(1,1,figsize=(12,6))

h.plot(ax)

The histogram comes by default with error bars. Different keyword parameters can be passed to customise the histogram.

fig,ax= plt.subplots(1,1,figsize=(12,6))
h.plot(ax,steps=True,ebar=False,filled=True)

Axes labels and titles can be passed to the plot function.

fig,ax= plt.subplots(1,1,figsize=(12,6))
h.plot(ax,steps=True,ebar=False,filled=True,xlabel='x (unit)',ylabel='y(unit)',title='Test')

Many times we have to fit gaussian to the histogram. An easy fit_normal method is provided with fits normal_distribution to the dateset.

h_fited = h.fit_normal()

Since the fitted object is an instance of Hist1D we can use the plot method as above to plot.

fig,ax= plt.subplots(1,1,figsize=(12,6))
h_fited.plot(ax,steps=True,ebar=False,filled=True,xlabel='x (unit)',ylabel='y(unit)',title='Test')

2D Histogram

The library naturally has Hist2D class for 2D histogram.

y = np.random.normal(2,3,10000)
h2d = eh.Hist2D((x,y),bins=200)

We can similarly plot the histogram.

fig,ax= plt.subplots(1,1,figsize=(12,6))
h2d.plot(ax,steps=True,ebar=False,filled=True,xlabel='x (unit)',ylabel='y(unit)',title='Test',cbarlabel='Colorbar',aspect='auto',cmin=1)

There are a lot of othe nice useful features which can be found in the documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easyhist-0.2.4.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

easyhist-0.2.4-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file easyhist-0.2.4.tar.gz.

File metadata

  • Download URL: easyhist-0.2.4.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for easyhist-0.2.4.tar.gz
Algorithm Hash digest
SHA256 389008455f38efa9ed3991898cb308d4564c9e2df698bf94d3163301c18c9c1d
MD5 fc55b326946cabecf1f38e18d6997a46
BLAKE2b-256 0f0acf43920fb3a39c359f814fbe38374981514c5b2a465c9e2b2ec129aa4af5

See more details on using hashes here.

File details

Details for the file easyhist-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: easyhist-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for easyhist-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8e162080925f3c13c627c1d7c11c8d4e51209e42acf93952806a302e0c0ba2ab
MD5 b4f7901b65e75ebd2d26bd1a844f8582
BLAKE2b-256 49b9b8441e5999632800b595a27e8559c2d750fd7d248de9b7116726dc52c96b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page