可以使用matplotlib.pyplot.rcParams来设置坐标轴的粗细,具体步骤如下:

  1. 导入matplotlib.pyplot模块。
import matplotlib.pyplot as plt
  1. 使用rcParams方法设置坐标轴线的粗细。例如,下面代码将x和y轴线的粗细都设置为2。
plt.rcParams['axes.linewidth'] = 2
  1. 绘制图形。
plt.plot(x, y)
plt.show()

完整示例代码:

import matplotlib.pyplot as plt

# 设置坐标轴线的粗细
plt.rcParams['axes.linewidth'] = 2 

# 绘制图形
x = [1, 2, 3, 4, 5]
y = [1, 4, 9, 16, 25]
plt.plot(x, y)

# 显示图形
plt.show()
Matplotlib 坐标轴粗细设置教程 - 详细步骤

原文地址: https://www.cveoy.top/t/topic/m1rw 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录