Choosing core tools to create charts and diagrams
D3 is a powerful tool for creating bespoke charts and diagrams, with a steep learning curve.
I recently wrote an essay on learning by writing essays[^1]. This was partly inspired by Stephen Wolfram’s recent 65th birthday essay, a lot of which is about his method of learning by writing what he calls computational essays. His essays are full of charts created with his own computer language (Wolfram Language). I would love to be able to do a similar thing, but I don’t want to use Wolfram’s method, mainly because his language is proprietary language. I want to use something open-source. But in order to use my chosen method I would need to get to know it really well, so that I can write functioning code to display charts and diagrams quickly and easily. But what should I choose? [^1]: Learning by writing essays
My first choice was to use Python with an appropriate visualization library.
Python:
- is a well designed language, which fairly easy to use and readable code.
- it is very widely used, and is a tool of choice for people who do statistics and data analysis.
- Lots of nice tools for data processing.
- I like it.
But then comes the process, and appropriate visualization library, and we run into some issues. I want my resulting diagrams and charts to look good, and also potentially be interactive and animated. Python is a server-side language, but the charts will be shown on the client side - i.e. in a browser. Browsers don’t run Python. (There are ways to do that, but they are a bit kludgy in my opinion). So Python visualization libraries that can create interactive and animated charts, such as Plotly, actually generate/use code in Javascript to do the client side interactivity and animation. Which is terribly limiting, as you are stuck with what the libraries provide. I want to be able to do not just charts, but also diagrams, and in fact any type of visual I can think of. Which means the logical choice of language is not Python, but Javascript. Ugh, Javascript. Ugh, Javascript.
Javascript:
- Very widely used in web development. (It’s really the only choice, as it is the only code that will run in the browser).
- Allows you to program amazing interactive animations, diagrams and charts.
- Lots of frameworks libraries available. In fact too many. Javascript programmers tend to have Shiny Toy Syndrome.
- It can be a bit ugly, hard to read and learn.
- I don’t like it very much.
Why don’t I like it very much? Because I don’t use it very much, and so I’ve never taken the time to get to know it in depth. So, I think I can see where this is heading… I need to learn Javascript in depth.
So my language of choice is Javascript, but what about an appropriate library for the diagrams and charting? When it comes to bespoke, sophisticated information visualizations, there really is only one choice. The hard-core information visualization experts all tend to use D3.
D3:
- Notoriously hard to use and difficult to read.
- Brilliant at making bespoke data visualizations.
- Generally well designed when it comes to visualization (Mike Bostock is a genius).
- A professional tool for data visualization.
- Possibly not the best choice for more general diagrams and animations though.
So it looks like I am going to be learning D3. I’ve used it before, and done a course on it in the past, but I want to get to the expert level, so that I can think of something I want to create and just type the code off the top of my head. And that’s going to take some serious learning. And now of course I have a great method for learning this type of thing — creating visual essays.
As I note above D3 is possibly not the best choice for general diagrams and animations. I may need to use something else for that, such as SVG.js. But initially trying to do everything with D3 will be a good way to learn it and its limitations.
I will still use Python as part of my process, to do data processing. What I could really do with now is a diagram to show my new process…