python绘制三维网格图,在Python Matplotlib中更改3D表面图中的网格线粗细

本文介绍了如何在Python的Matplotlib库中改变三维表面图的网格线的粗细和透明度。通过更新_Axinfo字典来设置轴的网格参数,例如`ax.yaxis._axinfo["grid"]['linewidth'] = 3.`可以改变Y轴网格线的宽度,`ax.zaxis._axinfo["grid"]['color'] = "#ee0009"`则可以设置Z轴网格线的颜色。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I'm trying to change the thickness and transparency of the lines that make up the grid in the background of a surface plot like this example from Matplotlib's website:

6ORKV.png

Here's the source code:

from mpl_toolkits.mplot3d import Axes3D

import matplotlib.pyplot as plt

from matplotlib import cm

from matplotlib.ticker import LinearLocator, FormatStrFormatter

import numpy as np

fig = plt.figure()

ax = fig.gca(projection='3d')

# Make data.

X = np.arange(-5, 5, 0.25)

Y = np.arange(-5, 5, 0.25)

X, Y = np.meshgrid(X, Y)

R = np.sqrt(X**2 + Y**2)

Z = np.sin(R)

# Plot the surface.

surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,

linewidth=0, antialiased=False)

# Customize the z axis.

ax.se

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值