forked from matplotlib/cheatsheets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
101 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# ----------------------------------------------------------------------------- | ||
# Matplotlib cheat sheet | ||
# Released under the BSD License | ||
# ----------------------------------------------------------------------------- | ||
|
||
# Scripts to generate all the basic plots | ||
import numpy as np | ||
import matplotlib as mpl | ||
import matplotlib.pyplot as plt | ||
import matplotlib.patheffects as path_effects | ||
|
||
fig = plt.figure(figsize=(2.15,2)) | ||
mpl.rcParams['axes.linewidth'] = 1.5 | ||
d = 0.01 | ||
ax = fig.add_axes([d,d,1-2*d,1-2*d], xticks=[], yticks=[]) | ||
|
||
np.random.seed(1) | ||
Z = np.random.uniform(0,1,(8,8)) | ||
cmap = plt.get_cmap("Oranges") | ||
im = ax.imshow(Z, interpolation="nearest", cmap=cmap, vmin=0, vmax=2) | ||
cb = fig.colorbar(im, fraction=0.046, pad=0.04) | ||
cb.set_ticks([]) | ||
|
||
plt.savefig("../figures/tip-colorbar.pdf") | ||
# plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# ---------------------------------------------------------------------------- | ||
# Title: Scientific Visualisation - Python & Matplotlib | ||
# Author: Nicolas P. Rougier | ||
# License: BSD | ||
# ---------------------------------------------------------------------------- | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import matplotlib.ticker as ticker | ||
|
||
# Setup a plot such that only the bottom spine is shown | ||
def setup(ax): | ||
ax.spines['right'].set_color('none') | ||
ax.spines['left'].set_color('none') | ||
ax.yaxis.set_major_locator(ticker.NullLocator()) | ||
ax.spines['top'].set_color('none') | ||
|
||
ax.spines['bottom'].set_position("center") | ||
|
||
ax.xaxis.set_ticks_position('bottom') | ||
ax.tick_params(which='major', width=1.00) | ||
ax.tick_params(which='major', length=5) | ||
ax.tick_params(which='minor', width=0.75) | ||
ax.tick_params(which='minor', length=2.5) | ||
ax.set_xlim(0, 5) | ||
ax.set_ylim(0, 1) | ||
ax.patch.set_alpha(0.0) | ||
|
||
|
||
fig = plt.figure(figsize=(5, .5)) | ||
fig.patch.set_alpha(0.0) | ||
n = 1 | ||
|
||
fontsize = 18 | ||
ax = plt.subplot(n, 1, 1) | ||
ax.tick_params(axis='both', which='minor', labelsize=6) | ||
setup(ax) | ||
ax.xaxis.set_major_locator(ticker.MultipleLocator(1.0)) | ||
ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.2)) | ||
ax.xaxis.set_major_formatter(ticker.ScalarFormatter()) | ||
ax.xaxis.set_minor_formatter(ticker.ScalarFormatter()) | ||
ax.tick_params(axis='x', which='minor', rotation=0) | ||
|
||
for tick in ax.get_xticklabels(): | ||
tick.set_fontname("Roboto Condensed") | ||
|
||
plt.tight_layout() | ||
plt.savefig("../figures/tip-font-family.pdf", transparent=True) | ||
# plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters