|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +""" |
| 3 | +============== |
| 4 | +Shifting Plots |
| 5 | +============== |
| 6 | +
|
| 7 | +Shift all your plots to the same location for blind uncertainty comparison. |
| 8 | +
|
| 9 | +
|
| 10 | +Plots will shift to the location you tell them to, in the same format as a truth dictionary. |
| 11 | +So you can use truth dict for both! Takes a list or a dict as input for convenience. |
| 12 | +
|
| 13 | +""" |
| 14 | + |
| 15 | +import numpy as np |
| 16 | +from numpy.random import multivariate_normal |
| 17 | +from chainconsumer import ChainConsumer |
| 18 | + |
| 19 | +np.random.seed(0) |
| 20 | +data1 = multivariate_normal([1, 0], [[3, 2], [2, 3]], size=300000) |
| 21 | +data2 = multivariate_normal([0, 0.5], [[1, -0.7], [-0.7, 1]], size=300000) |
| 22 | +data3 = multivariate_normal([2, -1], [[0.5, 0], [0, 0.5]], size=300000) |
| 23 | + |
| 24 | +############################################################################### |
| 25 | +# And this is how easy it is to shift them: |
| 26 | + |
| 27 | +truth = {"$x$": 1, "$y$": 0} |
| 28 | +c = ChainConsumer() |
| 29 | +c.add_chain(data1, parameters=["$x$", "$y$"], name="Chain A", shift_params=truth) |
| 30 | +c.add_chain(data2, name="Chain B", shift_params=truth) |
| 31 | +c.add_chain(data3, name="Chain C", shift_params=truth) |
| 32 | +fig = c.plotter.plot(truth=truth) |
| 33 | + |
| 34 | +fig.set_size_inches(2.5 + fig.get_size_inches()) # Resize fig for doco. You don't need this. |
| 35 | + |
| 36 | +############################################################################### |
| 37 | +# Here's without the shift: |
| 38 | + |
| 39 | +truth = {"$x$": 1, "$y$": 0} |
| 40 | +c = ChainConsumer() |
| 41 | +c.add_chain(data1, parameters=["$x$", "$y$"], name="Chain A") |
| 42 | +c.add_chain(data2, name="Chain B") |
| 43 | +c.add_chain(data3, name="Chain C") |
| 44 | +fig = c.plotter.plot(truth=truth) |
| 45 | + |
| 46 | +fig.set_size_inches(2.5 + fig.get_size_inches()) # Resize fig for doco. You don't need this. |
0 commit comments