Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 28 05:02
    coveralls commented #205
  • Jul 28 05:00
    coveralls commented #205
  • Jul 28 04:59
    coveralls commented #205
  • Jul 28 04:51

    tshead2 on main

    fixed deprecated numpy calls Merge pull request #205 from ha… (compare)

  • Jul 28 04:51
    tshead2 closed #205
  • Jul 28 04:51
    tshead2 reopened #205
  • Jul 28 04:50
    tshead2 closed #205
  • Jul 28 04:50
    tshead2 commented #205
  • Jul 28 04:44
    coveralls commented #205
  • Jul 28 04:41
    coveralls commented #205
  • Jul 28 04:41
    coveralls commented #205
  • Jul 25 22:31
    harmsm opened #205
  • Jul 05 19:50
    tshead2 commented #204
  • Jul 05 16:28
    ivan-marroquin closed #204
  • Jul 05 16:28
    ivan-marroquin commented #204
  • Jul 05 15:39
    tshead2 commented #204
  • Jul 01 16:44
    ivan-marroquin commented #204
  • Jun 30 15:28
    tshead2 commented #204
  • Jun 24 19:45
    ivan-marroquin commented #204
  • Jun 24 16:39
    tshead2 commented #204
matrixbot
@matrixbot

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 :))
Timothy M. Shead
@tshead
@hannes - this is expected behavior for Jupyter. If you use 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.
In a notebook, you can force PNG output instead of HTML output in a variety of ways. I think the clearest is to do
import IPython.display
IPython.display.Image(canvas)
Timothy M. Shead
@tshead

If you are generating lots of figures in a notebook and want to force them all to be rendered as PNG, do the following:

import toyplot.config
toyplot.config.autoformat = “png”

… and then every canvas will be automatically rendered as an inline PNG.

matrixbot
@matrixbot
hannes oh that is awesome
hannes thanks!
matrixbot
@matrixbot
hannes GSS79 (Gitter): you mean in labels etc? why not unicode :)
rahulroxx
@rahulroxx
Hey, I am new here can I work as substitute to matplotlib animation functions?
Timothy M. Shead
@tshead
@rahulroxx: (sorry if I’m misunderstanding your question) Toyplot figures support some limited forms of animation, yes.
Deren Eaton
@dereneaton
Hi @tshead , is it possible to modify the global defaults for toyplot, such as the default canvas height and width so that a user could set this just once at the top of a notebook?
Timothy M. Shead
@tshead
Those defaults currently live in toyplot.canvas.Canvas.init() … but they could be moved to toyplot.config instead. So in the short-term, your best bet would be to setup width and height variables at the top of your notebook and pass them to the API whever you’re creating plots.
Timothy M. Shead
@tshead
@dereneaton - I just pushed an update to allow canvas width and height to be set in toyplot.config. I’ll put together a formal release in the next couple of days … it’s been awhile.
matrixbot
@matrixbot
hannes your ock
hannes you rock
Eaton Lab
@eaton-lab
@tshead awesome!
Eaton Lab
@eaton-lab
@tshead , is it possible to create a colormap for matrix plotting that scales from a solid to transparent for a color? The goal is overlay several matrices and show the intensities of values in each layer as a different color. But I can't seem to figure out how to get transparencies in matrices currently.
Annoyingly, due to a quirk in the way toyplot.canvas.Canvas.matrix is implemented, you have to specify domain_min and domain_maxexplicitly 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).
Timothy M. Shead
@tshead
FWIW, overlaying visualizations like this isn’t really “The Toyplot Way”, since you have interactive features (tooltips, etc) that likely won’t behave properly. I guess what you really want is some kind of multi-dimensional color map that’s a generalization of the current scalar color maps, so you could create one matrix, but supply data that’s M x N x (number of features).
Eaton Lab
@eaton-lab
Thanks, yeah the layered plot didn't end up looking that great, but having several matrix plots side by side turned out to look really good. Thanks!
Timothy M. Shead
@tshead
Toyplot 0.17.0 Released - highlights include: H.264 animation output, restored functionality for animating text, config options for setting default canvas dimensions, and fewer requirements when creating matrix visualizations with custom colormaps. As usual, all the details are at http://toyplot.readthedocs.io/en/stable/release-notes.html … enjoy!
Eaton Lab
@eaton-lab
@tshead, is there an easy way to define certain marks to fit on the canvas (affect the domain) but not be included in tick marks? An example is that in toytree I use a single cartesian axes to draw the the graph and add text tip labels. When I add a scale bar (axes) I would like it to show only for the tree and not the text labels. Splitting it into two separate axes does not seem like an ideal solution. And I've tried setting the domain but then the text labels get cut off. I've started writing a custom mark object (which I hope to finish eventually) but even there I'm not sure exactly how to do this. Any tips? The following is an example:
image.png
I could make the scale bar a separate graph object, I suppose, instead of using the builtin axes, but I'm trying to maintain the style of toytree to be as compatible with Toyplot as possible.
Timothy M. Shead
@tshead
@eaton-lab, sounds like you want an explicit tick locator, take a look at https://github.com/sandialabs/toyplot/blob/master/sandbox/tick-repellent.ipynb and let me know if it’s what you have in mind.
Timothy M. Shead
@tshead2

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

matrixbot
@matrixbot
hannes nice!
Mohammed Yusuf Khan
@getmykhan
Hi, I just found this Awesome Library that I'm soon going to include in my guest lectures
I have a quick question, for plotting neural networks, is there a way to invert the plot?
matrixbot
@matrixbot
hannes Mohammed Yusuf Khan (Gitter): what do you mean? what kind of plot and what do you want to invert?
Timothy M. Shead
@tshead2
@getmykhan - If you haven’t already, take a look at the neural network case study at https://toyplot.readthedocs.io/en/stable/neural-network-case-study.html … what you’ll see there is that I’m assigning explicit coordinates for the nodes of the graph, so they can be organized into layers. You could easily flip that upside down, look for y = layer_map[layer] and negate it: y = -layer_map[layer].
Ideally, Toyplot should have a layout algorithm to handle this, but I haven’t had a chance to finalize the design (and there are so many possible ways to organize / display a network).
Mohammed Yusuf Khan
@getmykhan
@tshead2 , Yes, Thank I figured it out. There are definitely many ways to do it. Reshaping worked, but a simpler way to do it is vcoordinates.append((x, y)) -- > vcoordinates.append((y, x))
Yu-Cheng Huang
@amoshyc

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?
Imgur

Yu-Cheng Huang
@amoshyc

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!

Timothy M. Shead
@tshead
@amoshyc - Toyplot makes a distinction between data marks and drawing marks. Data marks (like rectangles) have domain data, and require a set of axes (cartesian in this case) to map that data to canvas coordinates. Drawing marks (like images) don’t have a domain, they’re simply placed on the canvas. So in this case, you’re making your cartesian domain equal to the resolution of the image, so one domain unit = one pixel. As it happens, I already have a recent request to support rectangles as drawing marks, which would probably behave more like what you’re expecting. Cheers, Tim.
Yu-Cheng Huang
@amoshyc
@tshead I see~ I' m looking forward to your future work. Currently what I need is to draw bounding boxes, keypoints, masks(polygons) on an image. An example is here. However, It seems that Toyplot doesn't have the ability to draw polygon and I would like to contribute. In this case, should I use Data Marks or Drawing Marks? If I stick to former, maybe I can utilize toyplot.graph but using latter is more logical.
I was using svgwrite previously, but it lacks of colormap and other high-level element. Are there any chance to make Toyplot able to add raw svg element directly? Although I don't think it is the purpose of this library. Thanks for the good library anyway XD
Timothy M. Shead
@tshead2
@amoshyc - A data mark is most appropriate when you have a data domain (typically with units) that should be affected by your choice of projection (for example: a linear process doesn’t look linear when using a log projection). For your purposes, polygons as drawing marks are probably the semantically right approach - presumably, you want to draw polygons around features in your image, so image / canvas coordinates are the most logical way to think about it.
Also: using graph marks as a short turn workaround to implement polys is a clever idea, albeit semantically wrong - long-term, Toyplot tries to get the semantics of marks right, so that they can provide additional, mark-centric interaction.
Yu-Cheng Huang
@amoshyc
Got it~
Timothy M. Shead
@tshead2

Toyplot and Python 2

Gang:

Just a reminder that Python 2 will no longer be maintained after January 1, 2020 (https://pythonclock.org), and Toyplot is one of a large number of scientific projects that are ending support for Python 2 prior to that date (https://python3statement.org). So here’s what to expect over the next few weeks:

  • Before December 31st, 2018, a Toyplot 0.18.0 release of the current master. This will be the final Toyplot release with Python 2 support.
  • After January 1st, 2019, I will begin removing Python 2 portability-related code from master, and stop running Python 2 regression tests on Travis.
  • Toyplot 0.18.0 will have its own branch (our releases are normally just tagged).
  • Pull requests with bug fixes against the 0.18.0 branch will be accepted on a case-by-case basis, for an indeterminate amount of time.

FWIW, I’ve been doing virtually all of my Toyplot development on Python 3 for over a year, without complaint. You should consider doing the same with your work. It’s time. Don’t panic.

Cheers,
Tim

Timothy M. Shead
@tshead2

@amoshyc asked:

Are there any chance to make Toyplot able to add raw svg element directly?

Sorry I overlooked this. We don’t support embedding directly, because it would complicate support for non-SVG backends. However, you can do this pretty easily as a postprocessing step. See the documentation for

… in either case, you can get the output as a DOM tree, suitable for further manipulation. The structure of the DOM is pretty clean, and there are CSS classes you can use to anchor queries.

Yu-Cheng Huang
@amoshyc
I'll take a look, thanks~
Timothy M. Shead
@tshead
Toyplot 0.18.0 Released - highlights include improvements to the format module, and new support for ellipse and range visualizations. Most importantly, 0.18 will be the final Toyplot release with Python 2 support. As usual, all the details are at http://toyplot.readthedocs.io/en/stable/release-notes.html … it’s a Festivus miracle!
matrixbot
@matrixbot
hannes merry christmas, you awesome person!