I'm looking for some suggestions about two problems:
1) I'm converting some figure generating code from IDL into
Python/matplotlib. Image attached showing this figure.
IDL being a functional programming language for the most part,
creating wrappers around various subroutines is trivial and generally
the simplest way to modify their behavior.
For example, in dealing with phase data (which can take values between
0º and 360º, and are 'wrapped' around this interval, such that 270º +
180º = 90º and so on), I have some stuff in IDL that instead over
simply 'overplotting' some (x,y) data, it will do a quick loop and
instead overplot (x, y + n * 360º) for n = -1, ..., 1 (or some other
number of repetitions, you get the idea).
Now, in matplotlib, while I can do this pretty easily, I suspect there
are better ways? I suppose I could write a subclass of
matplotlib.axes.Axes for example, that does the 360º repetition itself
across not just the plot() method but for others also? But
implementing a whole new class for this may be complicated, and I am
sort of lost as to how I would then get that working with the pylab
I'm reasonably new to OO programming, and I'm still getting my head
round the 'best' way to do things like this.
Alternatively, having a class that describes individual data points, I
could define a plot() method for them?
axes.plot(self.x, self.y + n * 360)
But then, that seems to 'break' some rules, as I don't see much
matplotlib code in which you do 'data.plot()' as opposed to
'axes.plot()' - the order seems wrong?
2) Somewhat similar to the first question. The figure includes (at
the top) some ancillary data (showing lengths of orbit and year
numbers). In IDL its done simply by filling polygons in normal / page
coordinates - but again, I think it could be better done using OO
somehow? Effectively, that top row could be thought of as a separate
subplot. What would be the efficient / sensible / pythonic way to go
about reproducing this. Another subclass of Axes?