From: Todd <tod...@gm...> - 2013-03-15 16:49:54
|
Currently, many of the plot types reside in axes. This makes sense from a structural standpoint, since the plots are generally a part of an axes. However, it makes things more difficult from a practical standpoint. First, it means that the axes class is huge, with both core axes-related methods and plotting-related methods. Second, it means that boilerplate.py has to be told explicitly which methods to use, rather than just grabbing everything from a module. Third, it makes it impossible to break the plot types into smaller groups of related plots. The solution, I think, is to move the plots into one or more modules and implement them as functions. They would have the same call signature as now, we would just replace "self" with "ax" or something like that. This would allow you to, theoretically, import and call them without axes, but this would probably not be common. Within the axes constructor, the constructor would run through each of these modules and store them as attributes with the same name as the function and the function itself being the contents. At least if me understanding is correct, this would make them behave as methods (since they are already set up to take an axes instance as their first argument). The axes would just be left with the methods related to manipulating the axes themselves. This would also simplify boilerplate.py, since it would simply need to know the names of the modules rather than the name of every plot type. It would then just run through the functions in the modules (or even just run through all modules in a particular directory). We would probably even be able to do away with that portion of boilerplate.py completely, creating the plotting functions in on-the-fly in pyplot at runtime, but that is a separate issue. What does everyone think of this approach? |