README.md 1.18 KB
Newer Older
Gregory Ashton's avatar
Gregory Ashton committed
1
# Grid corner plot
2

Gregory Ashton's avatar
Gregory Ashton committed
3
A corner plot for an array of dependent values
4

Gregory Ashton's avatar
Gregory Ashton committed
5
Given an N-dimensional set of data (i.e. some function evaluated over a grid
6
of coordinates), plot all possible 1D and 2D projections in the style of a
Gregory Ashton's avatar
Gregory Ashton committed
7
["corner" plot](http://corner.readthedocs.io/en/latest/pages/quickstart.html).
8

Gregory Ashton's avatar
Gregory Ashton committed
9
10
11
## Installation
Clone the repository and then
```bash
12
13
14
15
16
$ python setup.py install
```
or add a prefix to install in userspace, e.g.
```bash
$ python setup.py install --prefix=~/.local/
Gregory Ashton's avatar
Gregory Ashton committed
17
18
19
```

## Example
20
21
22
23
24

Generating some fake data and plotting:

```python
import numpy as np
Gregory Ashton's avatar
Gregory Ashton committed
25
import gridcorner
26
27
28
29
30
31
32
33
34
35
36
37
38
39

# Generate example data
x = np.linspace(0, 1, 50)
y = np.linspace(20, 30, 60)
z = np.linspace(-2, -1, 70)
x0, y0, z0 = 0.5, 22, -1.5
X, Y, Z = np.meshgrid(x, y, z, indexing='ij')
sigmax = 0.1
sigmay = 1
sigmaz = 0.2
D = (np.exp(-(X-x0)**2/sigmax**2)
     + np.exp(-(Y-y0)**2/sigmay**2)
     + np.exp(-(Z-z0)**2/sigmaz**2))

Gregory Ashton's avatar
Gregory Ashton committed
40
41
fig, axes = gridcorner.gridcorner(
    D, xyz=[x, y, z], labels=['x', 'y', 'z', 'D'], projection='log_mean')
42
43
44
45
fig.savefig('example')
```
![Example plot](example.png)

Gregory Ashton's avatar
Gregory Ashton committed
46
## Acknowledgements
47
48
49
50

The code uses both the central idea and some specific code from
[corner.py](https://github.com/dfm/corner.py)