tick的字体尺寸增加

发布于 2025-02-12 02:33:44 字数 860 浏览 1 评论 0原文

我有一个简单的x,y图,我想增加x和y轴上tick的字体,以便它们匹配x,y标签的字体大小 - fontsize = 30。我还需要更改两个轴上的间距,以使它们看起来或多或少地像下面的图片,尽管数据集不同。

提前致谢。

“我的情节”

我的代码:

import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
x = [1.53,0.84,0.7,0.6,0.53,0.47,0.38,0.35]
y = [19.64,14.33,11.25,7.58,2.84,0.87,0.36,0]
plt.plot(x, y, marker="o")

plt.xlabel(r'Grid spacing $\AA$', fontsize=20)
plt.ylabel('% error', fontsize=20)
plt.title('Protein solvation', fontsize=20)
plt.gca().invert_xaxis()

plt.show()

i have a simple x,y plot that i want to increase the font of of ticks on x and y axes, so that they match the font size of x,y labels - fontsize=30. i also need to change the spacing on both axes so that they look more or less like the picture below, although the data sets are different.

thanks in advance.

wished plot

my plot

my code:

import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
x = [1.53,0.84,0.7,0.6,0.53,0.47,0.38,0.35]
y = [19.64,14.33,11.25,7.58,2.84,0.87,0.36,0]
plt.plot(x, y, marker="o")

plt.xlabel(r'Grid spacing $\AA
, fontsize=20)
plt.ylabel('% error', fontsize=20)
plt.title('Protein solvation', fontsize=20)
plt.gca().invert_xaxis()

plt.show()

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

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

发布评论

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

评论(1

清风疏影 2025-02-19 02:33:44
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)


You can also use these functions to set the tick positions and labels:

plt.xticks(x, map(lambda x: f'{x:.2f}', x), fontsize=20, rotation=90)
plt.yticks([0, 10, 20], ['0', '10', '20'], fontsize=20)

”在此处输入图像说明”
(用plt.figure绘制(figsize =(12,6))

plt.xticks(fontsize=20)
plt.yticks(fontsize=20)

enter image description here


You can also use these functions to set the tick positions and labels:

plt.xticks(x, map(lambda x: f'{x:.2f}', x), fontsize=20, rotation=90)
plt.yticks([0, 10, 20], ['0', '10', '20'], fontsize=20)

enter image description here
(plotted with plt.figure(figsize=(12,6)))

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文