themeable is an abstract class of things that can be themed.
Every subclass of themeable is stored in a dict at
themeable.register with the name of the subclass as
It is the base of a class hierarchy that uses inheritance in a non-traditional manner. In the textbook use of class inheritance, superclasses are general and subclasses are specializations. In some since the hierarchy used here is the opposite in that superclasses are more specific than subclasses.
It is probably better to think if this hierarchy of leveraging
Python's multiple inheritance to implement composition. For example
axis_title themeable is composed of the
x_axis_title and the
y_axis_title. We are just using multiple inheritance to specify
When implementing a new themeable based on the ggplot2 documentation, it is important to keep this in mind and reverse the order of the "inherits from" in the documentation.
For example, to implement,
x axis label (element_text;
y axis label (element_text;
You would have this implementation:
class axis_title_x(themeable): ... class axis_title_y(themeable): ... class axis_title(axis_title_x, axis_title_y): ...
If the superclasses fully implement the subclass, the body of the subclass should be "pass". Python(__mro__) will do the right thing.
When a method does require implementation, call
then add the themeable's implementation to the axes.
A user should never create instances of class
subclasses of it.