/ / Kontrolle des Wertes der Xticks in Matplotlib - Python, Matplotlib

Kontrolle des Wertes der Xticks in Matplotlib - Python, Matplotlib

so fehlt mir wohl etwas Ja wirklich offensichtlich aber ...

Ich benutze den folgenden Code:

import matplotlib.pyplot as plt
import numpy as np

def f(t):
A = 2409.505
rho = 0.3260
C = 0.00
if C == 0.0:
return (A*np.exp(-t/rho))
else:
return (A*np.exp(-t/rho)) - (C/r**6)

t1 = np.arange(0, 15, 0.01)
plt.ylim(-0.005, 100)
plt.plot(f(t1), "b")
plt.tick_params(top = "off", right = "off")
plt.grid(linestyle = "--", linewidth = 0.05)
plt.show()

um folgende Handlung zu erstellen: Bildbeschreibung hier eingeben

Ich möchte jedoch, dass die Etiketten für die xticks 1 - 16 lauten. Kann jemand helfen?

Prost!

Antworten:

3 für die Antwort № 1
plt.plot(t1, f(t1), "b")

Wenn Sie nur eine 1D-Arrayliste zum Plotten übergeben. es nimmt die x-Achse an 1, 2, 3, .. auf die Länge Ihrer Arrayliste


0 für die Antwort № 2

Sie müssen das Array t1 als Ihre x-Variable in der Plot-Funktion übergeben:

plt.plot(t1, f(t1), "b")