diff --git a/plots/line_colours_from_colour_map.py b/plots/line_colours_from_colour_map.py new file mode 100644 index 0000000..a675cce --- /dev/null +++ b/plots/line_colours_from_colour_map.py @@ -0,0 +1,33 @@ +import os +import numpy as np +import matplotlib.pyplot as plt + +# Generate dummy data +delta = 0.3 +x = np.arange(-1.05, 1.1, delta) +y = np.arange(-1.05, 1.1, delta) +X, Y = np.meshgrid(x, y) +Z = X * Y + +# Generate colours from defined colours map +cmap = plt.get_cmap('RdYlGn', 10) +c = cmap(range(cmap.N)) + +# Remove light colours in middle of colour map +reds = c[:4, :] +greens = c[6:, :] +colours = np.vstack([reds, greens]) + +fig, ax = plt.subplots(1, 1, figsize=(6, 4)) + +for i in range(Z.shape[0]): + ax.plot(x, Z[i, :], c=colours[i], linewidth=3, alpha=0.6) + +# 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/line-colours-from-colour-map.png b/plots/png/line-colours-from-colour-map.png new file mode 100644 index 0000000..5eaf5b8 Binary files /dev/null and b/plots/png/line-colours-from-colour-map.png differ