These are chat archives for sandialabs/toyplot

14th
Jun 2017
Deren Eaton
@dereneaton
Jun 14 2017 22:07
@tshead2 On a related note: I'm interested in ways to reduce the size of the DOM that is produced by toyplot.html.render. In some cases I've run into the maximum-output error in jupyter b/c too much data was being printed to a cell. I noticed that for some objects, like a toyplot-mark-Text class object, the style dictionary is repeated in the DOM for every Toyplot-Datum <g> object, which makes the HTML huge when there are many points with lots of styling. Is there an easy way in toyplot -- outside of hacking the etree element itself -- to pass in a single style dict to the toyplot-mark-Text<g> object, so that all of the Toyplot-Datum objects inherit the style from their parent? Or is the best way to manipulate the xml.etree?
Deren Eaton
@dereneaton
Jun 14 2017 22:25

For example, the following code:

x = np.arange(5)
y = np.arange(5)
canvas = toyplot.Canvas(width=200, height=200)
axes = canvas.cartesian()
mark = axes.text(x, y, list("abcde"))

repeats the default dictionary for the text markers five times in the xml tree and DOM:

[('transform', 'translate(3.127343632818357,6)')]
[('y', '8.555'), ('x', '-2.78'), ('style', 'fill:rgb(16.1%,15.3%,14.1%);fill-opacity:1.0;font-family:helvetica;font-size:10.0;font-weight:normal;stroke:none;vertical-align:baseline;white-space:pre')]
[('transform', 'translate(26.56367181640918,6)')]
[('y', '8.555'), ('x', '-2.78'), ('style', 'fill:rgb(16.1%,15.3%,14.1%);fill-opacity:1.0;font-family:helvetica;font-size:10.0;font-weight:normal;stroke:none;vertical-align:baseline;white-space:pre')]
[('transform', 'translate(49.999999999999986,6)')]
[('y', '8.555'), ('x', '-2.78'), ('style', 'fill:rgb(16.1%,15.3%,14.1%);fill-opacity:1.0;font-family:helvetica;font-size:10.0;font-weight:normal;stroke:none;vertical-align:baseline;white-space:pre')]
[('transform', 'translate(73.4363281835908,6)')]
[('y', '8.555'), ('x', '-2.78'), ('style', 'fill:rgb(16.1%,15.3%,14.1%);fill-opacity:1.0;font-family:helvetica;font-size:10.0;font-weight:normal;stroke:none;vertical-align:baseline;white-space:pre')]
[('transform', 'translate(96.87265636718163,6)')]
[('y', '8.555'), ('x', '-2.78'), ('style', 'fill:rgb(16.1%,15.3%,14.1%);fill-opacity:1.0;font-family:helvetica;font-size:10.0;font-weight:normal;stroke:none;vertical-align:baseline;white-space:pre')]
Timothy M. Shead
@tshead2
Jun 14 2017 22:26
@dereneaton - If you’re talking about the style attribute of the <text> element, the repetition is an artifact of the new text rendering. This could be much smarter, but it probably won’t happen soon.
Deren Eaton
@dereneaton
Jun 14 2017 22:30
OK. Thanks. It's not so much a problem for text, I was just using that as a simple example, but where it really starts to cause problems for me is in graphs, where hundreds or thousands of edges start to create really large strings of data. It's only troublesome for particularly large plots, of course. For now maybe I'll just hack a solution for those particular types of plots.