更改具有相同标签的所有子图中 x/yticks 的字体大小

发布于 2025-01-20 17:15:18 字数 1383 浏览 5 评论 0原文

我正在尝试使每个子图的X/yticks的字体大小更大。我已经尝试使用

ax.set_xticklabels(xlabels,fontsize =)

但我不想指定新标签。我想要在图上默认的相同的(请参见下图)。总共有3个子图,我想增加所有子图的大小。

代码的一部分

markers = ['s','^','d','*','o']
colors = ['crimson', 'blueviolet', 'limegreen', 'mediumblue', 'hotpink']

fig,ax = plt.subplots(2, 2, dpi=300, figsize=(30, 25))
fig.delaxes(ax[1,1])
fig.tight_layout()
plt.rcParams['axes.grid'] = True
#plt.xticks(fontsize=24)

x=data['CPR']
y=data['DLP']
for xp, yp, m, c, t in zip(x,y,markers, colors, targets):
    ax[0,0].scatter(xp,yp,s=150,marker=m, color=c, label=t, zorder=1)
ax[0,0].errorbar(data['CPR'],data['DLP'],xerr=data['CPR_stddev'],yerr=data['DLP_stddev'],
               ls='none',
               ecolor='slategray',
               elinewidth=1,
               barsabove=False)  
ax[0,0].grid(color='gray', linestyle='--', linewidth=0.5)
ax[0,0].set_title('CPR vs DLP',fontsize='40')
handles, labels = ax[0,0].get_legend_handles_labels()
fig.legend(handles, labels, scatterpoints=1, borderpad=0.2, loc='upper left', fontsize=24)
ax[0,0].set_xlabel('CPR',fontsize=30)
ax[0,0].set_ylabel('DLP',fontsize=30)
ax[0,0].set_xlim([0,1.2])
####ax[0,0].set_xticks(fontsize=24)
plt.xticks(fontsize=24)
#plt.show()

“当前输出”

***研究海报 - 任何其他建议。

I'm trying to make the font size of the x/yticks of each subplot larger. I've tried using

ax.set_xticklabels(xlabels, Fontsize= )

but I don't want to specify new labels. I want the same ones that were defaulted on the plot (see image below). There are 3 total subplots and I'd like to increase the tick size of all of them.

Part of Code

markers = ['s','^','d','*','o']
colors = ['crimson', 'blueviolet', 'limegreen', 'mediumblue', 'hotpink']

fig,ax = plt.subplots(2, 2, dpi=300, figsize=(30, 25))
fig.delaxes(ax[1,1])
fig.tight_layout()
plt.rcParams['axes.grid'] = True
#plt.xticks(fontsize=24)

x=data['CPR']
y=data['DLP']
for xp, yp, m, c, t in zip(x,y,markers, colors, targets):
    ax[0,0].scatter(xp,yp,s=150,marker=m, color=c, label=t, zorder=1)
ax[0,0].errorbar(data['CPR'],data['DLP'],xerr=data['CPR_stddev'],yerr=data['DLP_stddev'],
               ls='none',
               ecolor='slategray',
               elinewidth=1,
               barsabove=False)  
ax[0,0].grid(color='gray', linestyle='--', linewidth=0.5)
ax[0,0].set_title('CPR vs DLP',fontsize='40')
handles, labels = ax[0,0].get_legend_handles_labels()
fig.legend(handles, labels, scatterpoints=1, borderpad=0.2, loc='upper left', fontsize=24)
ax[0,0].set_xlabel('CPR',fontsize=30)
ax[0,0].set_ylabel('DLP',fontsize=30)
ax[0,0].set_xlim([0,1.2])
####ax[0,0].set_xticks(fontsize=24)
plt.xticks(fontsize=24)
#plt.show()

Current output

***This is for a research poster -- any other recommendations welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

但可醉心 2025-01-27 17:15:18

尝试以下操作:

markers = ['s','^','d','*','o']
colors = ['crimson', 'blueviolet', 'limegreen', 'mediumblue', 'hotpink']

fig,ax = plt.subplots(2, 2, dpi=300, figsize=(30, 25))
fig.delaxes(ax[1,1])
fig.tight_layout()
plt.rcParams['axes.grid'] = True
#plt.xticks(fontsize=24)

x=data['CPR']
y=data['DLP']
for xp, yp, m, c, t in zip(x,y,markers, colors, targets):
    ax[0,0].scatter(xp,yp,s=150,marker=m, color=c, label=t, zorder=1)
ax[0,0].errorbar(data['CPR'],data['DLP'],xerr=data['CPR_stddev'],yerr=data['DLP_stddev'],
               ls='none',
               ecolor='slategray',
               elinewidth=1,
               barsabove=False)  
ax[0,0].grid(color='gray', linestyle='--', linewidth=0.5)
ax[0,0].set_title('CPR vs DLP',fontsize='40')
handles, labels = ax[0,0].get_legend_handles_labels()
fig.legend(handles, labels, scatterpoints=1, borderpad=0.2, loc='upper left', fontsize=24)
ax[0,0].set_xlabel('CPR',fontsize=30)
ax[0,0].set_ylabel('DLP',fontsize=30)
ax[0,0].set_xlim([0,1.2])

# loop over all axes
for a in ax.flatten():
    a.tick_params(axis='both', which='major', labelsize=24)
    a.tick_params(axis='both', which='minor', labelsize=20)
plt.tight_layout()
plt.show()

Try this:

markers = ['s','^','d','*','o']
colors = ['crimson', 'blueviolet', 'limegreen', 'mediumblue', 'hotpink']

fig,ax = plt.subplots(2, 2, dpi=300, figsize=(30, 25))
fig.delaxes(ax[1,1])
fig.tight_layout()
plt.rcParams['axes.grid'] = True
#plt.xticks(fontsize=24)

x=data['CPR']
y=data['DLP']
for xp, yp, m, c, t in zip(x,y,markers, colors, targets):
    ax[0,0].scatter(xp,yp,s=150,marker=m, color=c, label=t, zorder=1)
ax[0,0].errorbar(data['CPR'],data['DLP'],xerr=data['CPR_stddev'],yerr=data['DLP_stddev'],
               ls='none',
               ecolor='slategray',
               elinewidth=1,
               barsabove=False)  
ax[0,0].grid(color='gray', linestyle='--', linewidth=0.5)
ax[0,0].set_title('CPR vs DLP',fontsize='40')
handles, labels = ax[0,0].get_legend_handles_labels()
fig.legend(handles, labels, scatterpoints=1, borderpad=0.2, loc='upper left', fontsize=24)
ax[0,0].set_xlabel('CPR',fontsize=30)
ax[0,0].set_ylabel('DLP',fontsize=30)
ax[0,0].set_xlim([0,1.2])

# loop over all axes
for a in ax.flatten():
    a.tick_params(axis='both', which='major', labelsize=24)
    a.tick_params(axis='both', which='minor', labelsize=20)
plt.tight_layout()
plt.show()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文