tshead2 on main
fixed deprecated numpy calls Merge pull request #205 from ha… (compare)
logging
module configured to show warnings. you’ll never be caught by surprise.
networkx
, which is a dependency of colormath
, which we were using for colorspace conversion. I eliminated the need for colormath
, which greatly reduces our dependency footprint and makes me happy. On the feature side, you can now specify per-scatterplot-datum, per-axes, and and per-canvas hyperlinks, which can be handy if you’re embedding Toyplot figures in a web page. Note that this is in addition to the existing support for hyperlinks in text, which could be applied to labels, tick labels, legends, annotations, etc. There has been a lot of work done on the docstrings / API documentation, with more to come since this release was earlier than planned. Finally, thanks go to @dereneaton for helping fix a problem with text layout and @kannes for fixing a broken link in the documentation. As usual, details are at http://toyplot.readthedocs.io/en/stable/release-notes.html … enjoy!
hannes
hey, trying to plot 12742 x,y points in toyplot i get this in my jupyter notebook:
IOPub data rate exceeded.
The notebook server will temporarily stop sending output
to the client in order to avoid crashing it.
To change this limit, set the config variable--NotebookApp.iopub_data_rate_limit
.
hannes
expected or a bug?
hannes
oh, i guess the svg created is too huge
hannes
yeah, with toyplot.png.render(canvas, "figure1.png")
it worked, slow but no error
hannes
can i inline such png without much hassle? i would not want to write and read a tempfile by myself, this is just a tiny toy side dabbling
hannes
awesome convenience api :))
toyplot.png.render(canvas)
without a filename / file-like object, it returns the png data directly, so you can skip the round-trip to disk. See http://toyplot.readthedocs.io/en/stable/rendering.html for details.
import IPython.display
IPython.display.Image(canvas)
hannes
thanks!
toyplot.canvas.Canvas.matrix
is implemented, you have to specify domain_min
and domain_max
explicitly when you create your colormap(s). That shouldn’t strictly be necessary in all cases, so I may update the implementation to make it more forgiving (and provide useful warnings).
Gang:
If you aren’t aware of it, Python 2 will not be maintained after 2020 (https://pythonclock.org), and many scientific tools have pledged to stop supporting Python 2 along similar timelines (http://python3statement.org). Since numpy is a critical Toyplot dependency on that list, I decided to get out ahead of this and commit to a similar timeline. So: Toyplot will stop supporting Python 2 on December 31, 2018. Currently, all of my Toyplot development is on Python 3, and we have Python 2 and 3 builds on Travis to catch any regressions, so what this change will mean in practice is that the Python 2 build gets shut down.
For what it’s worth, I switched to Python 3 exclusively for all my work at the beginning of the year, and it has been fairly uneventful. The only time I’ve had to fall back to Python 2 was with a pair of commercial applications that embed it - module dependencies have been a complete non-issue.
Cheers,
Tim
y = layer_map[layer]
and negate it: y = -layer_map[layer]
.
Hello~ I'm doing a object detection project and want to use Toyplot for visualization when training. The code I tried so far is:
import numpy as np
import toyplot
import toyplot.svg
from skimage.data import astronaut
img = astronaut()
w, h = img.shape[:2]
canvas = toyplot.Canvas(width=w, height=h)
mark = canvas.image(img, rect=(0, 0, w, h))
axes = canvas.cartesian(show=False, margin=0, padding=0)
bbox = np.float32([
[22, 33, 44, 55],
]) # x1, x2, y1, y2
mark = axes.rects(bbox[:, 0], bbox[:, 1], bbox[:, 2], bbox[:, 3], style={
'stroke': 'orange',
'stroke-width': 2,
'fill-opacity': 0.0
})
toyplot.svg.render(canvas, './vis.svg')
However, the result seems incorrect. I expect a small rectangle but got a rectangle same size as the image. Are there any problem in the code? Or are there any other way to overlay bounding boxes on an image?
After tracing code, I found a solution. We need to specify xmin
, xmax
, ymin
, ymax
of cartesian
to make cartesian.project
work which is used by here. So
# Note the inversion of y-axis
axes = canvas.cartesian(show=False, margin=0, padding=0, xmin=0, xmax=w, ymin=h, ymax=0)
gets the desired result!
toyplot.graph
but using latter is more logical.