| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,18 +7,19 @@ | |||
| 7 | 7 | import matplotlib.pyplot as plt | |
| 8 | 8 | import numpy as np | |
| 9 | 9 | ||
| 10 | + plt.style.use('cheatsheet_gallery') | ||
| 11 | + | ||
| 10 | 12 | # make data | |
| 11 | 13 | X = np.linspace(0, 10, 100) | |
| 12 | 14 | Y = 4 + 2 * np.sin(2 * X) | |
| 13 | 15 | ||
| 14 | 16 | # plot | |
| 15 | - with plt.style.context('cheatsheet_gallery'): | ||
| 16 | - fig, ax = plt.subplots() | ||
| 17 | + fig, ax = plt.subplots() | ||
| 17 | 18 | ||
| 18 | - ax.plot(X, Y, linewidth=2.0) | ||
| 19 | + ax.plot(X, Y, linewidth=2.0) | ||
| 19 | 20 | ||
| 20 | - ax.set_xlim(0, 8) | ||
| 21 | - ax.set_xticks(np.arange(1, 8)) | ||
| 22 | - ax.set_ylim(0, 8) | ||
| 23 | - ax.set_yticks(np.arange(1, 8)) | ||
| 24 | - plt.show() | ||
| 21 | + ax.set_xlim(0, 8) | ||
| 22 | + ax.set_xticks(np.arange(1, 8)) | ||
| 23 | + ax.set_ylim(0, 8) | ||
| 24 | + ax.set_yticks(np.arange(1, 8)) | ||
| 25 | + plt.show() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,20 +6,21 @@ | |||
| 6 | 6 | import matplotlib.pyplot as plt | |
| 7 | 7 | import numpy as np | |
| 8 | 8 | ||
| 9 | + plt.style.use('cheatsheet_gallery') | ||
| 10 | + | ||
| 9 | 11 | # make the data | |
| 10 | 12 | np.random.seed(3) | |
| 11 | 13 | X = 4 + np.random.normal(0, 1.25, 24) | |
| 12 | 14 | Y = 4 + np.random.normal(0, 1.25, len(X)) | |
| 13 | 15 | ||
| 14 | 16 | # plot | |
| 15 | - with plt.style.context('cheatsheet_gallery'): | ||
| 16 | - fig, ax = plt.subplots() | ||
| 17 | + fig, ax = plt.subplots() | ||
| 17 | 18 | ||
| 18 | - ax.scatter(X, Y, 20, zorder=10, | ||
| 19 | - edgecolor="none", linewidth=0.25) | ||
| 19 | + ax.scatter(X, Y, 20, zorder=10, | ||
| 20 | + edgecolor="none", linewidth=0.25) | ||
| 20 | 21 | ||
| 21 | - ax.set_xlim(0, 8) | ||
| 22 | - ax.set_xticks(np.arange(1, 8)) | ||
| 23 | - ax.set_ylim(0, 8) | ||
| 24 | - ax.set_yticks(np.arange(1, 8)) | ||
| 25 | - plt.show() | ||
| 22 | + ax.set_xlim(0, 8) | ||
| 23 | + ax.set_xticks(np.arange(1, 8)) | ||
| 24 | + ax.set_ylim(0, 8) | ||
| 25 | + ax.set_yticks(np.arange(1, 8)) | ||
| 26 | + plt.show() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,20 +5,20 @@ | |||
| 5 | 5 | """ | |
| 6 | 6 | import matplotlib.pyplot as plt | |
| 7 | 7 | import numpy as np | |
| 8 | + plt.style.use('cheatsheet_gallery') | ||
| 8 | 9 | ||
| 9 | 10 | # make data: | |
| 10 | 11 | np.random.seed(3) | |
| 11 | 12 | X = 0.5 + np.arange(8) | |
| 12 | 13 | Y = np.random.uniform(2, 7, len(X)) | |
| 13 | 14 | ||
| 14 | 15 | # plot | |
| 15 | - with plt.style.context('cheatsheet_gallery'): | ||
| 16 | - fig, ax = plt.subplots() | ||
| 16 | + fig, ax = plt.subplots() | ||
| 17 | 17 | ||
| 18 | - ax.bar(X, Y, bottom=0, width=1, edgecolor="white", linewidth=0.7) | ||
| 18 | + ax.bar(X, Y, bottom=0, width=1, edgecolor="white", linewidth=0.7) | ||
| 19 | 19 | ||
| 20 | - ax.set_xlim(0, 8) | ||
| 21 | - ax.set_xticks(np.arange(1, 8)) | ||
| 22 | - ax.set_ylim(0, 8) | ||
| 23 | - ax.set_yticks(np.arange(1, 8)) | ||
| 24 | - plt.show() | ||
| 20 | + ax.set_xlim(0, 8) | ||
| 21 | + ax.set_xticks(np.arange(1, 8)) | ||
| 22 | + ax.set_ylim(0, 8) | ||
| 23 | + ax.set_yticks(np.arange(1, 8)) | ||
| 24 | + plt.show() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,19 +6,20 @@ | |||
| 6 | 6 | import matplotlib.pyplot as plt | |
| 7 | 7 | import numpy as np | |
| 8 | 8 | ||
| 9 | + plt.style.use('cheatsheet_gallery') | ||
| 10 | + | ||
| 9 | 11 | # make data | |
| 10 | 12 | np.random.seed(3) | |
| 11 | 13 | X = 0.5 + np.arange(8) | |
| 12 | 14 | Y = np.random.uniform(2, 7, len(X)) | |
| 13 | 15 | ||
| 14 | 16 | # plot | |
| 15 | - with plt.style.context('cheatsheet_gallery'): | ||
| 16 | - fig, ax = plt.subplots() | ||
| 17 | + fig, ax = plt.subplots() | ||
| 17 | 18 | ||
| 18 | - ax.stem(X, Y, bottom=0, linefmt="-", markerfmt="d") | ||
| 19 | + ax.stem(X, Y, bottom=0, linefmt="-", markerfmt="d") | ||
| 19 | 20 | ||
| 20 | - ax.set_xlim(0, 8) | ||
| 21 | - ax.set_xticks(np.arange(1, 8)) | ||
| 22 | - ax.set_ylim(0, 8) | ||
| 23 | - ax.set_yticks(np.arange(1, 8)) | ||
| 24 | - plt.show() | ||
| 21 | + ax.set_xlim(0, 8) | ||
| 22 | + ax.set_xticks(np.arange(1, 8)) | ||
| 23 | + ax.set_ylim(0, 8) | ||
| 24 | + ax.set_yticks(np.arange(1, 8)) | ||
| 25 | + plt.show() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,19 +6,20 @@ | |||
| 6 | 6 | import matplotlib.pyplot as plt | |
| 7 | 7 | import numpy as np | |
| 8 | 8 | ||
| 9 | + plt.style.use('cheatsheet_gallery') | ||
| 10 | + | ||
| 9 | 11 | # make data | |
| 10 | 12 | np.random.seed(3) | |
| 11 | 13 | X = 0.5 + np.arange(8) | |
| 12 | 14 | Y = np.random.uniform(2, 7, len(X)) | |
| 13 | 15 | ||
| 14 | 16 | # plot | |
| 15 | - with plt.style.context('cheatsheet_gallery'): | ||
| 16 | - fig, ax = plt.subplots() | ||
| 17 | + fig, ax = plt.subplots() | ||
| 17 | 18 | ||
| 18 | - ax.step(X, Y, linewidth=2.5) | ||
| 19 | + ax.step(X, Y, linewidth=2.5) | ||
| 19 | 20 | ||
| 20 | - ax.set_xlim(0, 8) | ||
| 21 | - ax.set_xticks(np.arange(1, 8)) | ||
| 22 | - ax.set_ylim(0, 8) | ||
| 23 | - ax.set_yticks(np.arange(1, 8)) | ||
| 24 | - plt.show() | ||
| 21 | + ax.set_xlim(0, 8) | ||
| 22 | + ax.set_xticks(np.arange(1, 8)) | ||
| 23 | + ax.set_ylim(0, 8) | ||
| 24 | + ax.set_yticks(np.arange(1, 8)) | ||
| 25 | + plt.show() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,24 +7,25 @@ | |||
| 7 | 7 | import matplotlib.pyplot as plt | |
| 8 | 8 | import numpy as np | |
| 9 | 9 | ||
| 10 | - # plot | ||
| 11 | - with plt.style.context('cheatsheet_gallery'): | ||
| 12 | - fig, ax = plt.subplots() | ||
| 10 | + plt.style.use('cheatsheet_gallery') | ||
| 11 | + | ||
| 13 | 12 | ||
| 14 | - # make data | ||
| 15 | - X = [1, 2, 3, 4] | ||
| 16 | - colors = np.zeros((len(X), 4)) | ||
| 17 | - colors[:] = mpl.colors.to_rgba("C0") | ||
| 18 | - colors[:, 3] = np.linspace(0.25, 0.75, len(X)) | ||
| 13 | + # make data | ||
| 14 | + X = [1, 2, 3, 4] | ||
| 15 | + colors = np.zeros((len(X), 4)) | ||
| 16 | + colors[:] = mpl.colors.to_rgba("C0") | ||
| 17 | + colors[:, 3] = np.linspace(0.25, 0.75, len(X)) | ||
| 19 | 18 | ||
| 20 | - ax.pie(X, colors=["white"]*len(X), radius=3, center=(4, 4), | ||
| 21 | - wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) | ||
| 22 | - ax.pie(X, colors=colors, radius=3, center=(4, 4), | ||
| 23 | - wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) | ||
| 19 | + # plot | ||
| 20 | + fig, ax = plt.subplots() | ||
| 21 | + ax.pie(X, colors=["white"]*len(X), radius=3, center=(4, 4), | ||
| 22 | + wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) | ||
| 23 | + ax.pie(X, colors=colors, radius=3, center=(4, 4), | ||
| 24 | + wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) | ||
| 24 | 25 | ||
| 25 | - ax.set_xlim(0, 8) | ||
| 26 | - ax.set_xticks(np.arange(1, 8)) | ||
| 27 | - ax.set_ylim(0, 8) | ||
| 28 | - ax.set_yticks(np.arange(1, 8)) | ||
| 26 | + ax.set_xlim(0, 8) | ||
| 27 | + ax.set_xticks(np.arange(1, 8)) | ||
| 28 | + ax.set_ylim(0, 8) | ||
| 29 | + ax.set_yticks(np.arange(1, 8)) | ||
| 29 | 30 | ||
| 30 | - plt.show() | ||
| 31 | + plt.show() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,22 +6,23 @@ | |||
| 6 | 6 | import matplotlib.pyplot as plt | |
| 7 | 7 | import numpy as np | |
| 8 | 8 | ||
| 9 | + plt.style.use('cheatsheet_gallery') | ||
| 10 | + | ||
| 9 | 11 | # make data | |
| 10 | 12 | np.random.seed(1) | |
| 11 | 13 | X = np.linspace(0, 8, 16) | |
| 12 | 14 | Y1 = 3 + 4*X/8 + np.random.uniform(0.0, 0.5, len(X)) | |
| 13 | 15 | Y2 = 1 + 2*X/8 + np.random.uniform(0.0, 0.5, len(X)) | |
| 14 | 16 | ||
| 15 | 17 | # plot | |
| 16 | - with plt.style.context('cheatsheet_gallery'): | ||
| 17 | - fig, ax = plt.subplots() | ||
| 18 | + fig, ax = plt.subplots() | ||
| 18 | 19 | ||
| 19 | - ax.fill_between(X, Y1, Y2, alpha=.5, linewidth=0) | ||
| 20 | - ax.plot(X, (Y1+Y2)/2, linewidth=2.5) | ||
| 20 | + ax.fill_between(X, Y1, Y2, alpha=.5, linewidth=0) | ||
| 21 | + ax.plot(X, (Y1+Y2)/2, linewidth=2.5) | ||
| 21 | 22 | ||
| 22 | - ax.set_xlim(0, 8) | ||
| 23 | - ax.set_xticks(np.arange(1, 8)) | ||
| 24 | - ax.set_ylim(0, 8) | ||
| 25 | - ax.set_yticks(np.arange(1, 8)) | ||
| 23 | + ax.set_xlim(0, 8) | ||
| 24 | + ax.set_xticks(np.arange(1, 8)) | ||
| 25 | + ax.set_ylim(0, 8) | ||
| 26 | + ax.set_yticks(np.arange(1, 8)) | ||
| 26 | 27 | ||
| 27 | - plt.show() | ||
| 28 | + plt.show() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,19 +7,20 @@ | |||
| 7 | 7 | import matplotlib.pyplot as plt | |
| 8 | 8 | import numpy as np | |
| 9 | 9 | ||
| 10 | + plt.style.use('cheatsheet_gallery') | ||
| 11 | + | ||
| 10 | 12 | # make data | |
| 11 | 13 | X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) | |
| 12 | 14 | Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) | |
| 13 | 15 | Z = Z - Z.min() | |
| 14 | 16 | Z = Z[::16, ::16] | |
| 15 | 17 | ||
| 16 | 18 | # plot | |
| 17 | - with plt.style.context('cheatsheet_gallery'): | ||
| 18 | - fig, ax = plt.subplots() | ||
| 19 | + fig, ax = plt.subplots() | ||
| 19 | 20 | ||
| 20 | - ax.imshow(Z, extent=[0, 8, 0, 8], interpolation="nearest", | ||
| 21 | - cmap=plt.get_cmap('Blues'), vmin=0, vmax=1.6) | ||
| 21 | + ax.imshow(Z, extent=[0, 8, 0, 8], interpolation="nearest", | ||
| 22 | + cmap=plt.get_cmap('Blues'), vmin=0, vmax=1.6) | ||
| 22 | 23 | ||
| 23 | - ax.set_xticks([]) | ||
| 24 | - ax.set_yticks([]) | ||
| 25 | - plt.show() | ||
| 24 | + ax.set_xticks([]) | ||
| 25 | + ax.set_yticks([]) | ||
| 26 | + plt.show() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,8 @@ | |||
| 10 | 10 | import matplotlib.pyplot as plt | |
| 11 | 11 | import numpy as np | |
| 12 | 12 | ||
| 13 | + plt.style.use('cheatsheet_gallery') | ||
| 14 | + | ||
| 13 | 15 | # make full-res data | |
| 14 | 16 | X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) | |
| 15 | 17 | Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) | |
@@ -24,9 +26,8 @@ | |||
| 24 | 26 | Z = Z[::8, :][:, xint] | |
| 25 | 27 | ||
| 26 | 28 | # plot | |
| 27 | - with plt.style.context('cheatsheet_gallery'): | ||
| 28 | - fig, ax = plt.subplots() | ||
| 29 | + fig, ax = plt.subplots() | ||
| 29 | 30 | ||
| 30 | - ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.5, shading='nearest') | ||
| 31 | + ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.5, shading='nearest') | ||
| 31 | 32 | ||
| 32 | - plt.show() | ||
| 33 | + plt.show() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,17 +6,18 @@ | |||
| 6 | 6 | import matplotlib.pyplot as plt | |
| 7 | 7 | import numpy as np | |
| 8 | 8 | ||
| 9 | + plt.style.use('cheatsheet_gallery') | ||
| 10 | + | ||
| 9 | 11 | # make data | |
| 10 | 12 | X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) | |
| 11 | 13 | Z = (1 - X/2. + X**5 + Y**3)*np.exp(-X**2-Y**2) | |
| 12 | 14 | Z = Z - Z.min() | |
| 13 | 15 | levs = np.linspace(np.min(Z), np.max(Z), 7) | |
| 14 | 16 | ||
| 15 | 17 | # plot | |
| 16 | - with plt.style.context('cheatsheet_gallery'): | ||
| 17 | - fig, ax = plt.subplots() | ||
| 18 | + fig, ax = plt.subplots() | ||
| 18 | 19 | ||
| 19 | - plt.contourf(X, Y, Z, levels=levs) | ||
| 20 | - plt.contour(X, Y, Z, levels=levs, colors="white", linewidths=0.5) | ||
| 20 | + plt.contourf(X, Y, Z, levels=levs) | ||
| 21 | + plt.contour(X, Y, Z, levels=levs, colors="white", linewidths=0.5) | ||
| 21 | 22 | ||
| 22 | - plt.show() | ||
| 23 | + plt.show() | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments