Here is one solution:
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import ScalarFormatter
# Read in data and calculate stellar temperature from the Ballesteros formula.
df = pd.read_csv('hygdata_v3-abridged.csv')
df['T'] = 4600 * (1/(0.92*df['ci'] + 1.7) + 1/(0.92*df['ci'] + 0.62))
# Fill NaN teperatures with 0.
df['T'].fillna(0, inplace=True)
# Assign stellar temperatures to bins: invalid data (formerly NaN temperatures)
# get assigned to the first bin. The temperature bin edges below categorize
# the stars by stellar type M, K, G, F, A, B, O. labels=False ensures that
# we get indexes and not category labels.
df['cidx'] = pd.cut(df['T'],
bins=(0, 2400, 3700, 5200, 6000, 7500, 10000, 30000),
labels=list('MKGFABO'), right=False)
star_rgbs = ('#ffffff', '#FFB56C', '#FFDAB5', '#FFEDE3', '#F9F5FF', '#D5E0FF',
'#A2C0FF', '#92B5FF')
color_mapping = {'M': '#FFB56C', 'K': '#FFDAB5', 'G': '#FFEDE3',
'F': '#F9F5FF', 'A': '#D5E0FF', 'B': '#A2C0FF',
'O': '#92B5FF'}
df['rgb'] = df['cidx'].map(color_mapping)
# Set the aspect ratio for maximum clarity.
DPI = 100
width, height = 600, 800
fig, ax = plt.subplots(figsize=(width/DPI, height/DPI), facecolor='k')
ax.set_facecolor('k')
# Log-log plot with suitable ticks and labels.
ax.scatter(df['T'], df['lum'], s=0.5, c=con['rgb'])
ax.set_yscale('log')
ax.set_xscale('log')
ax.set_ylim(1.e-6, 1.e5)
ax.set_xlim(30000,1000)
ax.set_xticks([30000, 10000, 5000, 3000, 1000])
# The chosen xticks don't get used unless we explicitly set a ScalarFormatter.
ax.get_xaxis().set_major_formatter(ScalarFormatter())
ax.set_xlabel('Temperature /K')
ax.set_ylabel('Luminosity relative to Sun')
plt.show()
The resulting image is shown below.
The banding effect here is because of the relatively low resolution of the temperature bins: it could be removed by interpolation or by using more bins.