From 0fe64dc43b39d8f71fa70cbc74964d42e3c4c889 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Thu, 22 Aug 2019 09:24:07 +1000 Subject: [PATCH] Add discrete_colour_ramp.py --- plots/README.md | 5 ++++ plots/discrete_colour_ramp.py | 39 +++++++++++++++++++++++++++++ plots/png/discrete-colour-ramp.png | Bin 0 -> 7731 bytes 3 files changed, 44 insertions(+) create mode 100644 plots/README.md create mode 100644 plots/discrete_colour_ramp.py create mode 100644 plots/png/discrete-colour-ramp.png diff --git a/plots/README.md b/plots/README.md new file mode 100644 index 0000000..b805512 --- /dev/null +++ b/plots/README.md @@ -0,0 +1,5 @@ +# plots + +## discrete_colour_ramp.py + +![discrete colour ramp](png/discrete-colour-ramp.png) diff --git a/plots/discrete_colour_ramp.py b/plots/discrete_colour_ramp.py new file mode 100644 index 0000000..2e5ab88 --- /dev/null +++ b/plots/discrete_colour_ramp.py @@ -0,0 +1,39 @@ +import os +import numpy as np +import matplotlib.pyplot as plt + +# Generate dummy data +delta = 0.01 +x = np.arange(-3.0, 3.0, delta) +y = np.arange(-3.0, 3.0, delta) +X, Y = np.meshgrid(x, y) +Z = X * Y + +# Set range and steps for colour bar +c_max = 8 +c_min = -8 +c_step = 2 + +# Create colour map +cmap = plt.cm.get_cmap('Blues', (c_max - c_min + c_step) / c_step) + +fig, ax = plt.subplots(1, 1, figsize=(6, 4)) + +# Plot image +im = ax.imshow(Z, + cmap=cmap, + interpolation='bilinear', + vmax=c_max + c_step / 2, + vmin=c_min - c_step / 2) + +# Add colour bar +plt.colorbar(im, ticks=np.arange(c_min, c_max + 1, c_step)) + +# Hide spines and ticks +ax.set_axis_off() + +# Export figure +png_name = os.path.join( + 'png', + os.path.basename(__file__).replace('.py', '.png').replace('_', '-')) +plt.savefig(png_name, bbox_inches='tight', dpi=100) diff --git a/plots/png/discrete-colour-ramp.png b/plots/png/discrete-colour-ramp.png new file mode 100644 index 0000000000000000000000000000000000000000..726fdd3a1baf81c9ef0299d6b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