diff --git a/hist.py b/hist.py new file mode 100644 index 0000000..795bd7d --- /dev/null +++ b/hist.py @@ -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() diff --git a/plot-1.py b/plot-1.py new file mode 100644 index 0000000..1d5c22b --- /dev/null +++ b/plot-1.py @@ -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) diff --git a/plot-2.py b/plot-2.py new file mode 100644 index 0000000..d380ef7 --- /dev/null +++ b/plot-2.py @@ -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() diff --git a/random-color-spot-plot.py b/random-color-spot-plot.py new file mode 100644 index 0000000..56f6337 --- /dev/null +++ b/random-color-spot-plot.py @@ -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() diff --git a/sub-plots.py b/sub-plots.py new file mode 100644 index 0000000..6c825af --- /dev/null +++ b/sub-plots.py @@ -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) diff --git a/x.png b/x.png new file mode 100644 index 0000000..c57f3f6 Binary files /dev/null and b/x.png differ