gpt4 book ai didi

python - 如何在 matplotlib 中在 3D 表面上绘制一条线

转载 作者:行者123 更新时间:2023-11-30 23:28:38 24 4
gpt4 key购买 nike

我有一个 3D 绘图,想在绘图表面绘制几条线。我不清楚应该如何组织线条数据以使其落在表面上。

对以下代码的一些解释:我对描述 Rubisco enzyme (在光合作用中至关重要) active 的温度敏感性参数进行了敏感性分析。活化能 Ha 是该方程中的唯一参数。

函数plot_TemperatureEffectOnRuBisCOKinetics绘制3D图。现在,我希望在表面上看到函数 TemperatureEffectOnRuBisCOKinetics 中描述的 4 个参数中每一个参数的行,并且每行都有很好的标签。

关于如何构建这些行的数据的一些提示将非常感激!

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

cRefTmp_C = 25. # [C]
cRefTmp_K = cRefTmp_C + 273.15 # [K]
MolarGasConstant = 8.314472 # [J mol-1 K-1]

def TemperatureEffectOnRuBisCOKinetics(Ha, LeafTemperature_C):
"""
multiplier for temperature effects on Kc, K0, Ri and GammaStar [ - ]
formula thesis Manfred Forstreuter p 66 (eq 2.41)

Parameter ParameterValue
cHaOfGammaStar 29000
cHaOfK0 35900
cHaOfKc 59500
cHaOfRi 46390

refs for equation:
Harley P.C., Thomas R.B., Reynolds J.F., Strain B.R., 1992.
Modelling photosynthesis of cotton grown in elevated CO2. Plant, Cell Environ. 15: 271-282.
Farquhar G.D., von Caemmerer S. & Berry J.A., 1980.
A biochemical model of photosynthetic CO2 assimilation in leaves of C3 species. Planta 149: 78-90.

"""
LeafTemperature_K = LeafTemperature_C + 273.15 # from Celsius to Kelvin
return exp(Ha * (LeafTemperature_K - cRefTmp_K) / (MolarGasConstant * LeafTemperature_K * cRefTmp_K))


def plot_TemperatureEffectOnRuBisCOKinetics():
Ha = np.arange(25000., 60000., 1000.)
T = np.arange(0., 30., 1)
Ha,T = np.meshgrid(Ha,T)
TEff = TemperatureEffectOnRuBisCOKinetics(Ha, T)

fig = plt.figure()
fig = plt.figure(facecolor='White')
ax = fig.gca(projection='3d')

surf = ax.plot_surface(Ha,T,TEff, rstride=1, cstride=1, cmap=cm.coolwarm,
linewidth=0, antialiased=False)

ax.set_zlim(TEff.min() ,TEff.max())
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
fig.colorbar(surf, shrink=0.5, aspect=5)

ax.set_title('Effect of temperature on Michaelis Menten-parameters \n at different Ha values')
ax.set_xlabel('Activation energy, Ha (J mol-1)')
ax.set_ylabel('Leaf surface temperature (C)')
ax.set_zlabel('T-multiplier to reference value')


plt.show()

plot_TemperatureEffectOnRuBisCOKinetics()

最佳答案

从你的问题中并不完全清楚你想要绘制哪些“线”,但我的猜测是你想要评估 TemperatureEffectOnRuBisCOKinetics 的一些固定值 Ha (cHaOfGammaStarcHaOfK0 等)和相同的温度值范围(0 到 30,步长为 1)。

例如,要绘制cHaOfGammaStar,您可以执行以下操作:

cHaOfGammaStar = np.array([29000])
z = TemperatureEffectOnRuBisCOKinetics(cHaOfGammaStar, T)

# we need to hold the axes to plot on top of the surface
ax.hold(True)

# we multiply cHaOfGammaStar by a vector of ones to make it the same length
# as T and z
l, = ax.plot(cHaOfGammaStar * np.ones(T.size), T, z, '--k')

# create a figure legend
ax.figure.legend((l,), ('cHaOfGammaStar',), loc=4, fancybox=True)

输出:

enter image description here

如果您想做一些更高级的注释而不仅仅是使用图形图例,您应该看看 HYRY's answer here .

关于python - 如何在 matplotlib 中在 3D 表面上绘制一条线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21529276/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com