8. Dark Rainbow plot
Dark rainbow plot

import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib.ticker import (MultipleLocator, FormatStrFormatter,
                                AutoMinorLocator)

matplotlib.rcParams['font.sans-serif'] = "Arial"
# Then, "ALWAYS use sans-serif fonts"
matplotlib.rcParams['font.family'] = "sans-serif"
matplotlib.rcParams['mathtext.fontset'] = 'dejavuserif' #'cm' or 'stix'


# Some plot variables

bgcolor=(0,0,0,0) # transparent black
axcolor = (74.0/255,173.0/255,234.0/255)

lfsize = 16 #label font size
tfsize = 14 #tick font size
lw = 2 #linewidth

x1 = 0
x2 = 100
xlabel = 'Temperature ($t_0$)'
y1 = 0
y2 = 20
ylabel = '$S/T$   (${\mathrm{k}_B}^2$/$t_0$)'

outfile = 'rainbow_dark.png'


# Create the figure
fig1 = plt.figure(figsize=(12,7))
fig1.patch.set_facecolor(bgcolor)
ax1 = fig1.add_subplot(1,1,1)


# Set up curve labels and colours
p = ['0.13','0.14','0.15','0.16','0.17','0.18','0.19','0.20','0.21','0.22','0.23','0.24','0.25','0.26','0.27','0.28']
evenly_spaced_interval = np.linspace(0, 1, len(p))
colors = [matplotlib.cm.rainbow(x) for x in evenly_spaced_interval]


# Plot some curves

T = np.linspace(0,100,10)

for i, color in enumerate(colors):
    g = np.linspace(0,1,10)*i
    ax1.plot(T,g, label=p[i], color=color, linewidth=lw, linestyle="-")


# Display the legend (in reverse order)
handles, labels = ax1.get_legend_handles_labels()   
ax1.legend(handles[::-1], labels[::-1],frameon=True,fontsize='large',loc=2,facecolor=bgcolor,framealpha=0,labelcolor=axcolor)


# Axes settings
ax1.tick_params('both', labelsize=tfsize, width=1,direction='in', pad=10, colors=axcolor);
ax1.set_xlabel(xlabel, fontsize=lfsize,labelpad=12, color=axcolor)
ax1.set_ylabel(ylabel,fontsize=lfsize,labelpad=12, color=axcolor)
ax1.set_xlim(x1,x2);
ax1.set_xticks(np.arange(0, 120, step=20))
ax1.xaxis.set_minor_locator(MultipleLocator(10))
ax1.tick_params(which='minor', length=3, width=2, color=axcolor, direction='in')
ax1.set_ylim(y1,y2)

ax1.spines['bottom'].set_linewidth(1.0)
ax1.spines['left'].set_linewidth(1.0)
ax1.spines['top'].set_linewidth(1.0)
ax1.spines['right'].set_linewidth(1.0)
ax1.spines['bottom'].set_color(axcolor)
ax1.spines['left'].set_color(axcolor)
ax1.spines['top'].set_color(axcolor)
ax1.spines['right'].set_color(axcolor)

ax1.axvline(x=60,linestyle='--', color='white', linewidth=1.0)

ax1.set_facecolor(bgcolor)

# Draw an arrow
style = "Simple, tail_width=0.5, head_width=4, head_length=8"
kw = dict(arrowstyle=style, color="w")
a3 = patches.FancyArrowPatch((80, 2), (80, 10), **kw)
ax1.add_patch(a3)

# Add figure panel text
fig1.text(-0.02,0.85,'(a)',color=axcolor,fontsize=lfsize)


# Save the figure to file
plt.savefig(outfile, format="png", bbox_inches='tight')
plt.show()