These are chat archives for sandialabs/toyplot

Oct 2015
Deren Eaton
Oct 19 2015 17:30
Is there an easy way to create a scale bar for a matrix visualization? My thought was to use toyplot.color.LinearMap() and to add text to it, but I'm hoping there is perhaps an easier function built in.
Timothy M. Shead
Oct 19 2015 17:42
So, there’s an undocumented colorbar feature in Toyplot that’s incomplete and lacking love. Here’s a quick example:
import numpy
import toyplot.color
data = numpy.random.normal(size=(16, 16))
palette = toyplot.color.brewer("BlueRed")
canvas = toyplot.Canvas(width=600)
matrix = canvas.matrix((data, palette), label="My Matrix")
axes = canvas.axes(show=False) = False
axes.colorbar(palette=palette, min=data.min(), max=data.max(), label="Color Scale”)
Timothy M. Shead
Oct 19 2015 17:49
Note that the colorbar can only be created using a set of axes (this is a misfeature), so this example creates a set of hidden axes occupying the same space on the canvas as the matrix. Also, the colorbar isn’t connected to the matrix in any way, so you have to explicitly specify a palette or map to both to get them to display the same colors and domain.
Overall I have to apologize for this example … it’s easily the ugliest corner in Toyplot :)