These are chat archives for sandialabs/toyplot

Mar 2017
Dr. Alexander Flint
Mar 18 2017 03:03
Screen Shot 2017-03-17 at 7.59.49 PM.png
Wondering if anyone else has encountered an issue with toyplot.scatterplot that engages connector lines after a certain number of points. Above is an example with 5000 points, below is 20000 points:
Screen Shot 2017-03-17 at 8.00.32 PM.png
Timothy M. Shead
Mar 18 2017 05:38
@neuroicudoc_twitter - That’s pretty bizarre, I tried to reproduce it with the following code, but it everything turned-out fine:
import numpy
import toyplot

x = numpy.random.uniform(-1, 1, 20000)
y = numpy.random.uniform(-1, 1, 20000)
color = numpy.sqrt(numpy.square(x) + numpy.square(y)) < 1.0

canvas, axes, mark = toyplot.scatterplot(x, y, color=color.astype("float"), size=2)

import toyplot.pdf
toyplot.pdf.render(canvas, "test.pdf")

import toyplot.png
toyplot.png.render(canvas, "test.png”)
I’d be interested to hear whether you get the same results with the above code. Also, what browser / platform are you using? Could you try a different browser (that’s assuming that you posted screencaps).
Dr. Alexander Flint
Mar 18 2017 18:24
Screen Shot 2017-03-18 at 11.18.52 AM.png
Screen Shot 2017-03-18 at 11.19.06 AM.png
Screen Shot 2017-03-18 at 11.19.14 AM.png
Interesting... So, I'm on Mac latest OS with latest Chrome and Safari, with Anaconda Python 2.7.11, using toyplot in a Jupyter Notebook with the above setup. The issue only happens in Chrome (screenshot with connecting lines), but the scatterplot is fine in Safari (the other screenshot).
Perhaps a clue... when I try the png render from your code either in the Jupyter Notebook or in command line IPython, I get an error at import:
In [63]: import toyplot.png
Exception                                 Traceback (most recent call last)
<ipython-input-63-75c489ab779a> in <module>()
----> 1 import toyplot.png

/Users/alexanderflint/anaconda/lib/python2.7/site-packages/toyplot/ in <module>()
     11 import toyplot.require
---> 12 import toyplot.reportlab.png as implementation

/Users/alexanderflint/anaconda/lib/python2.7/site-packages/toyplot/reportlab/ in <module>()
     23         break
     24 else:
---> 25     raise Exception("The gs executable is required.")  # pragma: no cover

Exception: The gs executable is required.
Dr. Alexander Flint
Mar 18 2017 18:37
No, on further inspection that looks like just a missing dependency used by the PNG render code... getting Ghostcript... shouldn't explain the connector line issue.
Timothy M. Shead
Mar 18 2017 18:51
So, confirmed that it’s a Chrome-specific issue, which I’m able to reproduce here. Interestingly, there isn’t a hard cutoff where things go wrong - if I try rendering 10000 points, it fails ~50% of the time. I’ll try a few more tests, such as whether displaying just the SVG without the notebook environment makes any difference.
Assuming that the symptoms are unchanged, the likely outcome will be a bug report to Chrome.
Thanks for reporting this!
Dr. Alexander Flint
Mar 18 2017 18:53
I got the same behavior, with so specific cutoff for the issue, but 10,000 points does seems like the ballpark for when it starts to happen, and by 20,000 points it seems to reliable occur.
Dr. Alexander Flint
Mar 18 2017 18:59

On the separate topic of the ghostscript dependency, install seems a bit dodgy on the Mac. From the ghostscript documentation, it looks like the options are (a) to install homebrew (which looks like a pip or conda alternate package installer), and then to install ghostscript, or (b) they provide a link to a Mac .pkg installer, but that's hosted on a third party website, so that makes me squirm a bit.

Any advise on the best way to proceed? By any chance are you considering basing future PNG / PDF rendering on a more common Python imaging library like pillows?

Timothy M. Shead
Mar 18 2017 23:11
I used MacPorts to install Ghostscript on my Mac, but Homebrew is a perfectly good alternative.
Timothy M. Shead
Mar 18 2017 23:17
Unfortunately, Pillow is not (really) a drawing library, and doesn’t have the features to produce good, high-quality figures. In an ideal world, we’d use Cairo + Pango to generate PDF and PNG output (in fact, an early version of Toyplot did just that), but they have an incredibly hostile build system that make them effectively Linux-only. So Ghostscript has been the least-worst cross-platform alternative.
If anyone wants to fork Cairo + Pango and make them cross-platform, you’d be doing a real service for the world, not just Toyplot :)
Last-but-not-least, I hope to encourage people to use HTML+SVG for the web, and PDF for publication. Ideally, you should never need PNG output for your figures.
Timothy M. Shead
Mar 18 2017 23:28
@neuroicudoc_twitter - just as I was writing-up a bug report for Chrome, a new update came through, to Version 57.0.2987.110 (64-bit). With the new version, I can’t reproduce the problem anymore, even bumping the plot up to 50000 points. You might try it out and see if it fixes things for you.