Coder Social home page Coder Social logo

b2plot's Introduction

b2plot

Description

Style and plotting tools for matplotlib.

Installation

Download this repository and run:

python3 ./setup.py develop --user

The matolotlib style can be installed in the sytlelib folder:

./install_mlp_style.sh

Usage

After installation you can use the style with matplotlib:

import matplotlib.pyplot as plt

plt.style.use('belle2')

One of the main features is the hist function, which can be used like matplotlib analogon, but has additional features, such as remembering the x-axis binning.

import b2plot

b2plot.hist(np.random.normal(0, 0.5, 1000))
b2plot.labels("O", "Entries", "Unit")

As the x-axis is stored, once you plot multible histograms or error bars on the same plot, all share the binning of the first.

import b2plot as bp

bp.hist(np.random.normal(0, 0.5, 1000), label="Pseudo Simulation")
bp.errorhist(np.random.normal(0, 0.5, 1000), label="Pseudo Data", color='black')

bp.labels("O", "Entries", "Unit")
plt.legend()

Example

Predefined styles make it easy to plot different histogram into one plot.

bp.hist(np.random.normal(0, 0.4, 1000), range=(-1, 8), label="None")
for i in range(6):
    bp.hist(np.random.normal(1+i, 0.4, 1000), style=i, label="Style %d"%i)

Example

Another feature is to create stacked histograms easily.

# Assuming a dataframe with columns "mass" and "exp"
bp.stacked(df, col="mass", by='exp', bins=50,)

Example

b2plot's People

Contributors

simonuu avatar lacaprara avatar

Watchers

James Cloos avatar Junyi Cheng avatar

Forkers

diptaparna

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.