mirror of
https://github.com/wahyd4/code-sandbox.git
synced 2026-08-09 05:07:03 +10:00
init code sandbox
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
.vscode
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
# data = np.random.randn(1000)
|
||||||
|
# plt.hist(data, bins=50)
|
||||||
|
# plt.show()
|
||||||
|
|
||||||
|
mean = [0, 0]
|
||||||
|
cov = [[1, 1], [1, 2]]
|
||||||
|
x, y = np.random.multivariate_normal(mean, cov, 10000).T
|
||||||
|
|
||||||
|
# plt.hist2d(x, y, bins=30, cmap="Blues")
|
||||||
|
plt.hexbin(x, y, gridsize=30, cmap="Oranges")
|
||||||
|
cb = plt.colorbar()
|
||||||
|
cb.set_label("counts in bin")
|
||||||
|
plt.show()
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import numpy as np
|
||||||
|
import matplotlib as matl
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import seaborn as sns
|
||||||
|
from IPython.display import Image
|
||||||
|
|
||||||
|
plt.style.use("seaborn-whitegrid")
|
||||||
|
|
||||||
|
x = np.linspace(0, 10, 100)
|
||||||
|
|
||||||
|
figure = plt.figure()
|
||||||
|
ax = plt.axes()
|
||||||
|
|
||||||
|
plt.plot(x, np.sin(x), "-", label="sin(x)")
|
||||||
|
plt.plot(x, np.cos(x), "o", label="cos(x)")
|
||||||
|
|
||||||
|
|
||||||
|
plt.legend()
|
||||||
|
|
||||||
|
plt.show(block=True)
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
rng = np.random.RandomState(0)
|
||||||
|
|
||||||
|
|
||||||
|
for marker in ["o", ".", ",", "x", "+", "v", "^", "<", ">", "s", "d"]:
|
||||||
|
plt.plot(rng.rand(5), rng.rand(5), marker, label="marker='{0}'".format(marker))
|
||||||
|
|
||||||
|
plt.legend(numpoints=1)
|
||||||
|
|
||||||
|
plt.xlim(0, 2)
|
||||||
|
|
||||||
|
plt.show()
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
rng = np.random.RandomState(0)
|
||||||
|
x = rng.randn(100)
|
||||||
|
y = rng.randn(100)
|
||||||
|
colors = rng.rand(100)
|
||||||
|
sizes = 1000 * rng.rand(100)
|
||||||
|
|
||||||
|
plt.scatter(x, y, c=colors, s=sizes, alpha=0.5, cmap="viridis")
|
||||||
|
plt.colorbar() # show color scale
|
||||||
|
|
||||||
|
plt.show()
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
|
||||||
|
plt.style.use("seaborn-whitegrid")
|
||||||
|
|
||||||
|
x = np.linspace(0, 10, 100)
|
||||||
|
|
||||||
|
figure = plt.figure()
|
||||||
|
ax = plt.axes()
|
||||||
|
sub1 = plt.subplot(2, 2, 1)
|
||||||
|
sub1.plot(x, np.sin(x), "-", label="sin(x)")
|
||||||
|
sub1.legend()
|
||||||
|
|
||||||
|
sub2 = plt.subplot(2, 2, 2)
|
||||||
|
sub2 = plt.plot(x, np.cos(x), "o", label="cos(x)")
|
||||||
|
sub2 = plt.legend()
|
||||||
|
|
||||||
|
plt.subplot(2, 2, 3)
|
||||||
|
plt.plot(x, np.tan(x), "-", label="tan(x)")
|
||||||
|
plt.legend()
|
||||||
|
|
||||||
|
|
||||||
|
plt.show(block=True)
|
||||||
Reference in New Issue
Block a user