ich muss euch heute gleich noch mal etwas fragen. Ich hatte eine private Diskussion über Drücke und Geschwindigkeiten und da dachte ich mir, das wäre doch cool in einem 3D-Diagram. Seit gestern Abend mache ich daran rum und bekomme es nicht hin, dass die x-Achse richtig dargestellt ist. Stand jetzt ist die total unbeeindruckt von der z-Achse. Das ist aber nicht so, mit steigendem Druck erhalte ich auch eine höhere Beschleunigung, ich erwarte, dass die Fläche sich hier auch erhebt, so wie man es bei der Geschwindigkeit sieht. An sich sind das alles fiktive Werte und das Ergebnis ist daher auch egal, ich will nur für die Zukunft, falls ich es mal brauche, wissen wie ich das Diagram richtig darstelle.
`pressures` muss ein 2D-Array sein, deshalb Zeile 29.
Code: Alles auswählen
#!/usr/bin/env python
from math import pi
import matplotlib.pyplot as plt
import numpy as np
# In kilo gram
WEIGHT_OF_CAP = 1
#
# In meter
DIAMETER_OF_CAP = 0.1
DISTANCE_TO_WALL = 0.5
START_PRESSURE = 1
END_PRESSURE = 200
def main():
pressures = np.arange(START_PRESSURE, END_PRESSURE, 1)
forces = np.array(pressures * 1e5 * pi * DIAMETER_OF_CAP**2 / 4)
accelerations = np.array(forces / WEIGHT_OF_CAP)
velocities = np.array((2 * DISTANCE_TO_WALL * accelerations) ** 0.5)
accelerations, velocities = np.meshgrid(
accelerations,
velocities,
)
pressures = np.array([[pressure] for pressure in pressures])
figure, axis = plt.subplots(subplot_kw={"projection": "3d"})
surf = axis.plot_surface(
accelerations, velocities, pressures, cmap="hot", alpha=0.8, edgecolor="none"
)
axis.set_xlabel("Acceleration [m/s²]")
axis.set_ylabel("Velocity [m/s]")
axis.set_zlabel("Pressure [bar]")
plt.show()
if __name__ == "__main__":
main()
Dennis