@@ -33,27 +33,49 @@ pip install -e .
3333Simply importing ` probscale ` lets you use probability scales in your matplotlib figures:
3434
3535``` python
36- import matplotlib.pyplot as plt
37- import probscale
38-
39- fig, ax = plt.subplots(figsize = (8 , 4 ))
40- ax.set_ylim(1e-2 , 1e2 )
41- ax.set_yscale(' log' )
42-
43- ax.set_xlim(0.5 , 99.5 )
44- ax.set_xscale(' prob' )
36+ from matplotlib import pyplot
37+ from scipy import stats
38+ import probscale # nothing else needed
39+
40+ beta = stats.beta(a = 3 , b = 4 )
41+ weibull = stats.weibull_min(c = 5 )
42+ scales = [
43+ {" scale" : {" value" : " linear" }, " label" : " Linear (built-in)" },
44+ {" scale" : {" value" : " log" , " base" : 10 }, " label" : " Log. Base 10 (built-in)" },
45+ {" scale" : {" value" : " log" , " base" : 2 }, " label" : " Log. Base 2 (built-in)" },
46+ {" scale" : {" value" : " logit" }, " label" : " Logit (built-in)" },
47+ {" scale" : {" value" : " prob" }, " label" : " Standard Normal Probability (this package)" },
48+ {
49+ " scale" : {" value" : " prob" , " dist" : weibull},
50+ " label" : " Weibull probability scale, c=5 (this package)" ,
51+ },
52+ {
53+ " scale" : {" value" : " prob" , " dist" : beta},
54+ " label" : " Beta probability scale, α=3 & β=4 (this package)" ,
55+ },
56+ ]
57+
58+ N = len (scales)
59+ fig, axes = pyplot.subplots(nrows = N, figsize = (9 , N - 1 ), constrained_layout = True )
60+ for scale, ax in zip (scales, axes.flat):
61+ ax.set_xscale(** scale[" scale" ])
62+ ax.text(0.0 , 0.1 , scale[" label" ] + " →" , transform = ax.transAxes)
63+ ax.set_xlim(left = 0.5 , right = 99.5 )
64+ ax.set_yticks([])
65+ ax.spines.left.set_visible(False )
66+ ax.spines.right.set_visible(False )
67+ ax.spines.top.set_visible(False )
68+
69+ outpath = Path(__file__ ).parent.joinpath(" ../img/example.png" ).resolve()
70+ fig.savefig(outpath, dpi = 300 )
4571```
4672
4773![ Alt text] ( docs/img/example.png " Example axes ")
4874
4975## Testing
5076
51- Testing is generally done via the `` pytest `` and `` numpy.testing `` modules.
52- The best way to run the tests is in an interactive python session:
77+ Testing is generally done via `` pytest `` .
5378
54- ``` python
55- import matplotlib
56- matplotlib.use(' agg' )
57- from probscale import tests
58- tests.test()
79+ ``` shell
80+ python -m pytest --mpl --doctest-glob=" probscale/*.py"
5981```
0 commit comments