I have a 3d plot and would like to draw several lines over the surface of the plot. It is not clear to me how I should organize the data of the lines so that it fall on the surface.
Some explanation for the code below: I made a sensitivity analysis on the temperature sensitivity parameters describing the activity of the Rubisco enzym (crucial in photosynthesis). The activation energy, Ha
, is the only parameter in this equation.
The function plot_TemperatureEffectOnRuBisCOKinetics
draws the 3D plot. Now I would like to see the lines for each of the 4 parameters described in the function TemperatureEffectOnRuBisCOKinetics
on the surface, with each line nicely labelled.
Some tips on how to structure the data for these lines would be very much appreciated!
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()
It's not totally clear from your question which 'lines' you are trying to plot, but my guess is that you want to evaluate TemperatureEffectOnRuBisCOKinetics
for some fixed values of Ha
( cHaOfGammaStar
, cHaOfK0
etc.) and the same range of temperature values (0 to 30 in steps of 1).
For example, to plot cHaOfGammaStar
you could do something like this:
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)
If you want to do some fancier annotation rather than just using a figure legend, you should take a look at HYRY's answer here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.