#!/usr/bin/env python # coding: utf-8 # # Plotting physt histograms # # Some matplotlib-based plotting examples, with no exhaustive documentation. # In[1]: # Necessary import evil import physt from physt import h1, h2, histogramdd from physt.plotting import matplotlib import numpy as np import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') np.random.seed(42) from physt import plotting # In[2]: # Some data x = np.random.normal(100, 1, 10000) y = np.random.normal(10, 10, 10000) # In[3]: ax = h2(x, y, 15).plot(figsize=(6, 6), show_zero=False, alpha=0, text_color="black", show_values=True, cmap="BuGn_r", show_colorbar=False, transform=lambda x:1) h2(x, y, 50).plot.image(cmap="Spectral_r", alpha=0.75, ax=ax) # In[4]: h2(x, y, 40, name="Gauss").plot("image", cmap="rainbow", figsize=(5, 5)) # In[5]: plotting.matplotlib.bar3d(h2(x, y, 10, name="Gauss"), figsize=(5, 5), cmap="Accent"); # In[6]: h1(x, "human", 10, name="Gauss").plot(ylim=(100, 1020), cmap="Greys", ticks="edge", errors=True); # In[7]: h1(x, "human", 200, name="Gauss").plot.line(errors=True, yscale="log") # In[8]: h1(x, "human", 200, name="Gauss").plot.fill(lw=1, alpha=.4, figsize=(8, 4)) h1(x, "human", 200, name="Gauss").plot.fill(lw=1, alpha=.4, yscale="log", figsize=(8, 4), color="red") # In[9]: h1(x, "human", 200, name="Gauss").plot.scatter(errors=True, xlim=(90, 100), show_stats="all") # In[10]: ha = h1(x, "human", 20, name="Left") hb = h1(x + 1 * np.sin(x / 12), "human", 40, name="Right") from physt.plotting.matplotlib import pair_bars # In[11]: pair_bars(ha, hb, density=True, errors=True, figsize=(5, 5)); # ## Example - histogram of time values # In[12]: # Get values close to from physt.plotting.common import TimeTickHandler data = np.random.normal(3600, 900, 4800) H = h1(data, "human", axis_name="time") H.plot(tick_handler=TimeTickHandler())