2017-12-20 2 views
0

Lesen der Matplotlib-Dokumentation, es sieht aus wie Stil ist ein Modul von Matplotlib (Matplotlib.style).Ist Stil ein Modul von Matplotlib oder Matplotlib.pyplot?

Allerdings habe ich diesen Code gesehen: matplotlib.pyplot.style.use (‚Seaborn‘)

Ich verstehe nicht, wie die Stil-Modul kann mit (und von genannt) in Verbindung gebracht wird die matplotlib .pyplot Modul.

Antwort

0

Matplotlib hat ein Modul style. Dies kann wie

from matplotlib import style 

Die obige Linie importiert werden ist auch im Inneren des pyplot.py.
style ist somit im Namensraum von pyplot und Sie können

matplotlib.pyplot.style.use("some_style") 
+0

Dank tun! In der Sprache der objektorientierten Programmierung bedeutet dies, dass das Importieren des 'style' Moduls in' matplotlib.pyplot' 'style' ein Attribut von' matplotlib.pyplot' macht? – titiree

+0

Da pyplot keine Klasse ist, kann 'style' kein Attribut sein. Es ist immer noch ein (Sub-) Modul. Dieses Submodul befindet sich im Namensraum von pyplot. – ImportanceOfBeingErnest

Verwandte Themen