The code for the plotms tool is in gcwrap/tools/plotms/  These methods are invoked via SWIG from the python task interface, with commands sent to the casaplotms process by DBus XML messages.  Most of the plotms code can be found in code/plotms.  See the Global Task List Developer page for the plotms task for more information.