-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
executable file
·74 lines (57 loc) · 1.71 KB
/
test.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 9 14:31:19 2019
@author: loveday
"""
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
def cbar():
cmap = mpl.cm.viridis
norm = mpl.colors.Normalize(vmin=12.8, vmax=14.2)
scalarMap = mpl.cm.ScalarMappable(norm=norm, cmap=cmap)
plt.clf()
fig, axes = plt.subplots(3, 2, sharex=True, sharey=True, num=1)
fig.subplots_adjust(top=0.93)
cbar_ax = fig.add_axes([0.13, 0.97, 0.75, 0.02])
cb = mpl.colorbar.ColorbarBase(cbar_ax, cmap=cmap, norm=norm,
orientation='horizontal')
plt.axis((-2, 1, -20, -15))
plt.show()
def polar():
# Fixing random state for reproducibility
np.random.seed(19680801)
# Compute areas and colors
N = 150
r = 2 * np.random.rand(N)
theta = 2 * np.pi * np.random.rand(N)
area = 200 * r**2
colors = theta
fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
ax.set_thetamin(120)
ax.set_thetamax(135)
ax.set_xlabel('RA')
ax.set_ylabel('z')
plt.show()
def scatter(nsmall=10000, nlarge=100):
plt.clf()
x, y = np.random.random(nsmall), np.random.random(nsmall)
plt.scatter(x, y, s=0.1, c='k', alpha=0.5)
x, y, c = np.random.random(nlarge), np.random.random(nlarge), np.random.random(nlarge)
plt.scatter(x, y, s=100, c=c, alpha=1)
plt.savefig('test_scatter.png', bbox_inches='tight')
plt.show()
def argtest():
def fun_list(arg=[1, 2]):
print(arg)
arg[0] = 9
def fun(arg=1):
print(arg)
arg = 9
fun()
fun()
fun_list()
fun_list()