For certain highly formalized types of diagrams - for example flow charts -, PlantUML is great, and since it uses a textual language, it could be wired to a lot of different programs.
MetaPost ist similar but a bit lower level. It can generate very complex diagrams for arbitrary content.For example, I used it once to draw and publish a globe-like 3D sphere with fields depicting different spherical probability values in it.
Racket, a Scheme descendent, is very nice for elementary graphics - it can output pictures in the REPL of its integrated IDE, DrRacket. And it can output these seamlessly as vector graphics, or into interactive user interfaces, too. It also has an elementary but good graphing package. I have used it for a web app which did some data analysis, presented it as a plot in SVG format in the browser, and provided a PDF for download. Neat!
And then there is Python with Matplotlib. It is made for almost every imaginable visualization of numerical data.
For 3D data, there is VTK, which has bindings for C++, Tcl/Tk, Java, and Python.
And TeX/LaTeX with various graphing packages.
As said, all of these can be used programmatically, and can be included in other systems, as long as the latter can generate text commands which can piped into these special-languages, or library calls.