import matplotlib.pyplot as plt import numpy as np from matplotlib import rcParams Use a…
- User
import matplotlib.pyplot as plt import numpy as np from matplotlib import rcParams
Use a commonly available serif font
rcParams.update({ "font.family": "serif", "font.serif": ["DejaVu Serif"], "font.size": 12, "axes.labelsize": 14, "axes.titlesize": 16, "xtick.labelsize": 12, "ytick.labelsize": 12, "legend.fontsize": 11, "lines.linewidth": 1.8, "axes.linewidth": 1.5, "xtick.major.width": 1.2, "ytick.major.width": 1.2, "text.usetex": False, "figure.dpi": 600, "savefig.dpi": 600, "figure.autolayout": True })
Load band data
try: data = np.loadtxt('ti3in_bands.dat.gnu') k = np.unique(data[:, 0]) bands = data[:, 1].reshape(-1, len(k)) except FileNotFoundError: raise FileNotFoundError("Band structure data file 'ti3in_bands.dat.gnu' not found.")
Fermi energy
fermi_energy = 13.7295
High-symmetry points
sym_indices = [0, 40, 80, 120, 160, 200, 240, 280] sym_points = [k[i] for i in sym_indices] sym_labels = [r'Γ', 'M', 'K', r'Γ', 'A', 'L', 'H', 'A']
fig, ax = plt.subplots(figsize=(8, 6))
Colormap for highlighted bands (crossing)
cmap = plt.get_cmap('tab20') num_colors = cmap.N # 20 distinct colors
Identify bands crossing the Fermi energy
crossing_bands_indices = [] for i, band in enumerate(bands): # Check if band crosses Fermi energy: i.e., # minimum < E_F < maximum OR maximum < E_F < minimum (bands can be decreasing) if np.min(band) <= fermi_energy <= np.max(band): crossing_bands_indices.append(i)
Plot all bands in light gray (background)
for i, band in enumerate(bands): band_clipped = np.clip(band, 11, 16) ax.plot(k, band_clipped-fermi_energy, color='olive', alpha=0.8, linewidth=1)
Plot crossing bands with distinct colors and stronger alpha
for idx_i, i in enumerate(crossing_bands_indices): band = bands[i] band_clipped = np.clip(band, 11, 16) color = cmap(idx_i % num_colors) ax.plot(k, band_clipped-fermi_energy, color=color, alpha=1, linewidth=2.2, label=f'Band {i+1}')
Fermi energy line
ax.axhline(fermi_energy, linestyle='--', color='red', linewidth=1.5) ax.text(k[0] - 0.13, fermi_energy-0.02, r'', color='red', fontsize=12)
- Assistant
- User
how to change position of ax.set_ylabel(r"E - (eV)") text
- Assistant
To change the position of the y-axis label (
ax.set_ylabel()), you can use thelabelpadparameter (to increase or decrease the distance from the axis) or theset_ylabel()method with thelocparameter (to change alignment). For more fine-tuned control, you can access the label text object returned byax.set_ylabel()and use its method to set exact coordinates.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.