Easy Python graphics with SVG output?
March 1, 2019 1:05 PM   Subscribe

I use plot.ly a lot for making figures. It's a lot cleaner and easier to use than matplotlib, which I have used, and it has a well-documented Python library. But it costs $100/year to be able to download plots in .svg format. Is there a good library for plotting in Python that outputs high-resolution figures? I'm willing to pay money for the feature, but my budget is closer to $35/year for a student version or $100 for a lifetime use.

I don't care about hosting or anything else; I really just want to be able to download high-res files. If it's got a GUI, the ability to work on Linux either natively or via WINE in some form (including playonlinux, crossover, etc) is necessary. I'm willing to bend on .svg; .html or any other format that scales nicely with size is fine. But I don't want to rely on .png or .jpeg outputs only; they look fuzzy and unprofessional.
posted by sciatrix to Computers & Internet (8 answers total) 6 users marked this as a favorite
 
What are your requirements for a GUI? Would something like Jupyter work? (lots of stackoverflow questions address how to print SVGs using Python in Jupyter).

Most plotting libraries can output SVG or EPS, but it sometimes requires fiddling around with rendering back ends. For example, here's how to do it on matplotlib. If you're not trying to plot graphs, but just want to draw figures at a lower level, look in the direction the cairo Python library.
posted by qxntpqbbbqxl at 1:33 PM on March 1, 2019


Incidentally, for my dissertation's graphs, I tried at first to go the vector graphics route but (for reasons lost to history) eventually just went with PNGs. You can get them to look good if you increase the DPI before rendering.
posted by qxntpqbbbqxl at 1:36 PM on March 1, 2019


Response by poster: Currently, I'm using python in Atom; before that I mostly ran it in the command line terminal. I've actually never used Jupyter, but less GUI is probably easier on me than more.
posted by sciatrix at 1:37 PM on March 1, 2019


seaborn is a slightly more usable open source alternative to matplotlib, but it's essentially just a matplotlib wrapper.

bokeh is very popular. It's focused on interactive web plots, but will write to SVG.

But it's worth taking the time to learn matplotlib (e.g. from the relevant chapters in Jake Vanderplas's book, rather than the official documentation). I'm not going to defend its API or usability, but it has huge community momentum and is not going anywhere. Other than ease of use, did you have any specific concerns about matplotlib?

If for some reason you want to know why matplotlib is the way it is (e.g. you're cursing the creators for the nth time, or you're interested in object-oriented library design patterns ca. 2005), then this chapter from The Architecture of Open Source Applications is very interesting! (But absolutely unnecessary for end use of matplotlib. I just think it's interesting.)

Jupyter is not a plotting library. It makes one or two things easier from your point of view, and most (but not all) people find it easier to use for working on plots because of the tigher feedback loop, but it's not really relevant to this question.
posted by caek at 1:39 PM on March 1, 2019 [1 favorite]


I'm an MPL user, but I've been tempted recently to start migrating to Bokeh. I don't have much first-hand experience but it does look like they have native SVG export.

(On preview, Jupyter isn't really a GUI but it does make making figures a lot easier -- definitely recommend trying it out. It's not a replacement for a plotting library though. It works with MPL, plotly, etc.)
posted by no regrets, coyote at 1:41 PM on March 1, 2019


I’m a day-to-day python user, but I’m surrounded by R users, and the plotting options in the R ecosystem are kind of amazing. I know more than one scientist who does all their heavy science work in Python but does the actual pretty graphs in R.
posted by rockindata at 1:52 PM on March 1, 2019 [3 favorites]


Also, if you've only spent a bit of time with Matplotlib and found it a pain I definitely recommend trying again. I found it annoying at first but once it clicked it was great. Bokeh and plotly give you great out-of-the-box plots but MPL is just so much more customizable.

Most of the documentation uses the pyplot interface, which I find really non-intuitive. I didn't really "get" MPL until I started exclusively using the object oriented interface which I find way easier. This example matches pretty well with how I use MPL.

(Of course, not liking MPL is fine too. To each their own.)
posted by no regrets, coyote at 2:16 PM on March 1, 2019 [1 favorite]


Spitballing: you can pull many graphs and plots from Excel into Inkscape for SVGlicious tweaking. You can trace even relatively complex generated bitmaps too.

Draw.io can import simple data structures and output to svg.

TikZ is a powerful tool for generating vector graphics based on geometric and algebraic description.

It may help you get better answers if we get some info on what types of figures/plots you want to make.
posted by SaltySalticid at 5:27 PM on March 1, 2019


« Older Why is my espresso maker so slow?   |   Man, that hit the spot! Newer »
This thread is closed to new comments.