import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
设置中文字体(以SimHei为例)
font = FontProperties(fname=“C:/Windows/Fonts/simhei.ttf”, size=12)
提取第一列和第二列的数据
x = new_df[new_df.columns[0]].values
y = new_df[new_df.columns[1]].values
创建带有IEEE科技论文风格和网格背景的散点图
with plt.style.context([‘science’, ‘ieee’, ‘grid’, ‘no-latex’]):
plt.figure(figsize=(10, 6)) # 可选:设置图形大小
plt.scatter(x, y, alpha=0.5) # 创建散点图,alpha参数控制透明度
# 添加中文标签和标题
plt.xlabel('发病到首次影像检查时间间隔', fontproperties=font)
plt.ylabel('ED_volume', fontproperties=font)
plt.title('发病到首次影像检查时间间隔 vs. ED_volume', fontproperties=font)
# 显示图形
plt.show()