-
Notifications
You must be signed in to change notification settings - Fork 0
/
mathplotlib 8.py
43 lines (34 loc) · 1.23 KB
/
mathplotlib 8.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
#-*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name: matplotlib changement de couleurs conditionnel
# Purpose:
# https://matplotlib.org/gallery/index.html
# Author: Jean
# http://apprendre-python.com/page-creer-graphiques-scientifiques-python-apprendre
# Created: 23/01/2018
# Copyright: (c) Jean 2018
# Licence: <your licence>
#-------------------------------------------------------------------------------
from matplotlib import pyplot as plt
import matplotlib.colors as mcolors
import numpy as np
from numpy.random import multivariate_normal
data = np.vstack([
multivariate_normal([10, 10], [[3, 2], [2, 3]], size=100000),
multivariate_normal([30, 20], [[2, 3], [1, 3]], size=1000)
])
gammas = [0.8, 0.5, 0.3]
fig, axes = plt.subplots(nrows=2, ncols=2)
axes[0, 0].set_title('Linear normalization')
axes[0, 0].hist2d(data[:, 0], data[:, 1], bins=100)
for ax, gamma in zip(axes.flat[1:], gammas):
ax.set_title('Power law $(\gamma=%1.1f)$' % gamma)
ax.hist2d(data[:, 0], data[:, 1],
bins=100, norm=mcolors.PowerNorm(gamma))
fig.tight_layout()
plt.show()
def main():
pass
if __name__ == '__main__':
main()