科研作图细节
- 设置字体大小为14:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
plt.rcParams.update({'font.size': 14})
plt.savefig('plot.eps', format='eps')
- 使用斜体:
ax.text(x_position, y_position, r'$\it{text in italics}$', fontsize=14)
ax.set_title(r'$\it{Title in Italics}$', fontsize=14)
- 手工调整纵坐标位置:
ax.set_ylim(0.75, 0.8)
- 绘制虚线和实线,并调整线条粗细:
ax.plot(x_data, y_data, linestyle='--', linewidth=1.5)
ax.plot(x_data, y_data, linestyle='-', linewidth=2.0)
- 保存为PNG文件:
plt.savefig('plot.png', format='png', dpi=300)
- 创建子图(subplot)和放大镜:
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5))
ax2.set_xlim(x_start, x_end)
ax2.set_ylim(y_start, y_end)
ax1.add_patch(plt.Rectangle((x_start, y_start), x_end - x_start, y_end - y_start, fill=False, edgecolor='red', linewidth=2))