Matplotlib.axes.Axes.get_xscale() in Python
Matplotlib ist eine Bibliothek in Python und eine numerisch-mathematische Erweiterung für die NumPy-Bibliothek. Die Achsenklasse enthält die meisten Figurenelemente: Achse, Häkchen, Linie2D, Text, Polygon usw. und legt das Koordinatensystem fest. Die Instanzen von Axes unterstützen Rückrufe über ein Rückrufattribut.
matplotlib.axes.Axes.get_xscale() Funktion
Die Funktion Axes.get_xscale() im Achsenmodul der matplotlib-Bibliothek wird verwendet, um die x-Achsenskala als Zeichenfolge zurückzugeben.
Syntax: Axes.get_xscale (self)
Parameter: Diese Methode akzeptiert keine Parameter.
Rückgabe: Diese Funktion gibt die x-Achsen-Skala als Zeichenfolge zurück.
Die folgenden Beispiele veranschaulichen die Funktion matplotlib.axes.Axes.set_yscale() in matplotlib.axes:
Beispiel 1:
import
matplotlib.pyplot as plt
import
numpy as np
fig, ax
=
plt.subplots()
ax.plot([
1
,
2
,
3
])
w
=
ax.get_xscale()
ax.set_title(
"xscale property : "
+
str
(w),
fontweight
=
"bold"
)
fig.suptitle('matplotlib.axes.Axes.get_xscale()\
function Example\n', fontweight
=
"bold"
)
fig.canvas.draw()
plt.show()
Ausgabe:
Beispiel 2:
import
matplotlib.pyplot as plt
import
numpy as np
from
matplotlib.ticker
import
EngFormatter
val
=
np.random.RandomState(
19680801
)
xs
=
np.logspace(
1
,
9
,
100
)
ys
=
(
0.8
+
4
*
val.uniform(size
=
100
))
*
np.log10(xs)
*
*
2
fig, ax0
=
plt.subplots()
ax0.set_xscale(
'log'
)
formatter0
=
EngFormatter(unit
=
'Hz'
)
ax0.xaxis.set_major_formatter(formatter0)
ax0.plot(xs, ys)
ax0.set_xlabel(
'Frequency'
)
w
=
ax0.get_xscale()
ax0.set_title(
"xscale property : "
+
str
(w),
fontweight
=
"bold"
)
fig.suptitle('matplotlib.axes.Axes.get_xscale()\
function Example\n', fontweight
=
"bold"
)
fig.canvas.draw()
plt.show()
Ausgabe: