0

Reading the matplotlib documentation, it looks like style is a module of matplotlib (matplotlib.style).

However, I've seen this code: matplotlib.pyplot.style.use('seaborn')

I don't understand how the style module can be associated with (and called from) the matplotlib.pyplot module.

1 Answer 1

1

Matplotlib has a module style. This can be imported like

from matplotlib import style

The above line is also present inside the pyplot.py.
style is thus in the namespace of pyplot and you can do

matplotlib.pyplot.style.use("some_style")
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! In the language of object-oriented programming, does this mean that importing the style module in matplotlib.pyplot makes style an attribute of matplotlib.pyplot?
Since pyplot is not a class, style cannot be an attribute. It is still a (sub)module. This submodule is in the namespace of pyplot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.