Python 我如何要求绘制一个三维图形,其中一个变量是用户输入变量?
所以我在Linux机器上的Jupyter笔记本中使用matplotlib。我遇到的问题是,当我在绘图时要求用户输入时,我似乎无法绘制图形 有没有一种方法可以用两个或三个变化的变量绘制三维图形,其中一个变化的变量由用户输入Python 我如何要求绘制一个三维图形,其中一个变量是用户输入变量?,python,python-3.x,matplotlib,jupyter-notebook,matplotlib-animation,Python,Python 3.x,Matplotlib,Jupyter Notebook,Matplotlib Animation,所以我在Linux机器上的Jupyter笔记本中使用matplotlib。我遇到的问题是,当我在绘图时要求用户输入时,我似乎无法绘制图形 有没有一种方法可以用两个或三个变化的变量绘制三维图形,其中一个变化的变量由用户输入 import matplotlib as mlp from matplotlib import pyplot as plt import numpy as np import math import time from mpl_toolkits.mplot3d import
import matplotlib as mlp
from matplotlib import pyplot as plt
import numpy as np
import math
import time
from mpl_toolkits.mplot3d import Axes3D
pi = math.pi
boltzmanns_constant = (10 ** -23) * 1.38064852
radius = float(input("Please enter the radius of the oxidant: "))
prefactor = 1
monolayer_surface_tension = float(input("Please enter the monolayer surface tension: "))
%matplotlib notebook
from matplotlib.animation import FuncAnimation
from matplotlib.widgets import RadioButtons
from itertools import count
import random
import mplcursors
index = count()
fig = plt.figure()
x_vals = []
y_vals = []
z_vals = []
axes = fig.add_subplot(111, projection='3d')
plt.rcParams['figure.figsize'] = (20,30)
plt.rcParams['figure.dpi'] = 150
def animate(i):
# monolayer_surface_tension = float(input("Please enter the monolayer surface tension: "))
plt.xlabel("Time In Seconds")
plt.ylabel("Radius")
axes.set_zlabel("K-Value")
#plt.x_label("Time (seconds)")
plt.rcParams['axes.labelcolor'] = "Red"
k_value = prefactor * -((pi * (radius*radius) * monolayer_surface_tension))
x_vals.append(next(index))
y_vals.append(radius)
z_vals.append(k_value)
plt.tight_layout()
plt.cla()
plt.pause(4)
input()
axes.plot(x_vals, y_vals, z_vals)
mplcursors.cursor(hover=True)
monolayer_surface_tension = float(input("Please enter the monolayer surface tension: "))
ani = FuncAnimation(plt.gcf(), animate, interval=1000)
plt.show()
mplcursors.cursor(hover=True)
如何在动画(i)
中使用i?我不认为你需要动画,你需要的是你的参数滑动条。