Most of the projects we develop in our company are build up on Windows stack. To be more precise — .NET/C#. There is one disadvantage of .NET which comes up especially in research/data analysis tasks. It is a lack of charting libraries. Or maybe it will be fairer to say that there is a lack of good charting libraries. Good enough to be compared to Python’s matplotlib or Gnuplot. There are plenty of projects, open source and commercial, but from my perspective, they all are either “dead” or being developed from the point of view of someone needs.
So we decided to build up a bridge between C# and Python’s matplotlib. In a few words the approach is this:
- Create a set of classes both in C# and Python which describe a task (what and how to plot). Let’s call these types a protocol in this post.
- Create a python script which launches the Flask web-service at localhost and can accept HTTP requests. Primitive “Web-API” with a single method.
- In C# implement a proxy class which can pass a task (a set of protocol classes) to the Flask app, task serialized in JSON. This C# proxy also launches the Python script if it is not up and running.