<jupyter_start><jupyter_text>empiricaldist plotting functionsCopyright 2019 <NAME>BSD 3-clause license: https://opensource.org/licenses/BSD-3-Clause<jupyter_code>%matplotlib inline

import numpy as np
import pandas as pd

import matplotlib.pyplot as plt
from empiricaldist import Pmf
pmf = Pmf.from_seq([1, 2, 2, 4, 5], name='example')
pmf.plot()
plt.legend();
pmf.bar()
plt.legend();
xs = [1,2,3,4]
ys = [0.15, 0.35, 0.25, 0.2]

pmf.plot()

plt.plot(xs, ys)
cdf = pmf.make_cdf()
cdf.plot()
plt.legend();
cdf.step()
plt.legend();
surv = cdf.make_surv()
surv.plot()
plt.legend();
surv = cdf.make_surv()
surv.step()
plt.legend();
haz = surv.make_hazard()
haz.plot()
plt.legend();
haz.bar()
plt.legend();<jupyter_output>No handles with labels found to put in legend.<jupyter_text>Replicating a problem with plotting Pmfs<jupyter_code>unbiased = np.array([ 5,  6, 12,  7,  8,  6,  6,  9,  8,  4,  3,  5,  5,  7,  5,  7,  4,
        4,  3,  6,  3,  5, 10,  1,  7,  4,  8,  2,  9,  6,  5,  5,  9, 11,
       11,  3,  9,  1, 10,  1,  6,  6,  5,  8,  7,  7,  4,  7,  2,  1,  3,
        1,  6,  3,  1,  1,  2,  2,  1,  2,  2,  1])
pmf = Pmf.from_seq(unbiased)
pmf.bar(label='')
from scipy.stats import poisson

mean = np.mean(unbiased)

qs = np.arange(1, 13)
ps = poisson.pmf(qs, mean)
plt.plot(qs, ps, color='C1', label='model')
pmf.bar()
plt.plot(qs, ps, color='C1', label='model')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18447293447293447, 'fraction_numerical': 0.0698005698005698, 'mean_word_length': 3.561688311688312, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 17, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '231020', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 712, 'n_tokens_neox': 659, 'n_words': 166, 'path': 'empiricaldist/test_plot.ipynb', 'repo_name': 'AllenDowney/empyricaldist', 'size': '1410'}