Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 19 16:29
    StuntsPT commented #202
  • Feb 18 18:49

    tshead2 on main

    Bump version number. (compare)

  • Feb 18 18:44

    tshead2 on v1.0.1

    (compare)

  • Feb 18 18:43

    tshead2 on main

    Update our compatibility statem… Toyplot version 1.0.1 (compare)

  • Feb 18 18:10

    tshead2 on main

    Additional fixes to sync with c… (compare)

  • Feb 18 17:01

    tshead2 on main

    Begin testing with Python 3.10. (compare)

  • Feb 18 16:58
    tshead2 commented #202
  • Feb 18 16:58

    tshead2 on main

    Makes toyplot work with python … Merge pull request #202 from St… (compare)

  • Feb 18 16:58
    tshead2 closed #202
  • Feb 18 16:51
    coveralls commented #202
  • Feb 14 12:54
    StuntsPT opened #202
  • Jan 07 23:56

    tshead2 on main

    Begin exploring graphcat and xm… (compare)

  • Jan 07 07:32

    tshead2 on main

    Bump version number. (compare)

  • Jan 07 07:30

    tshead2 on v1.0.0

    (compare)

  • Jan 07 07:30

    tshead2 on main

    Toyplot version 1.0.0 (compare)

  • Jan 07 06:26

    tshead2 on main

    Add missing modules to the docu… (compare)

  • Jan 07 05:47

    tshead2 on main

    We don't need to combine parall… (compare)

  • Jan 07 05:14

    tshead2 on main

    Temporarily disable Eades graph… (compare)

  • Jan 07 04:59

    tshead2 on main

    Do a DOM comparison for HTML ar… (compare)

  • Jan 07 03:55

    tshead2 on main

    Add missing CI dependency. (compare)

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!
matrixbot
@matrixbot
hannes is https://toyplot.readthedocs.io/en/stable/tick-locators.html#explicit-locators the "proper" way of labeling categories in a bar chart? my x axis is categorical
Timothy M. Shead
@tshead
@hannes - yep, that’s the way to do it. While you’re at it, don’t forget that you can use rich text in your labels.
matrixbot
@matrixbot
hannes cheers
matrixbot
@matrixbot
hannes is there a single line way to set toyplot to render png instead of svg when embedded in jupyter notebook?
hannes i would like to render some bigger matrix
Timothy M. Shead
@tshead
@matrixbot - when you create your canvas, add autoformat=“png”.

If you find that you’re doing it a lot, you can also do

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

to make it the default (at the top of your notebook, say).

matrixbot
@matrixbot
hannes ah nice!, thanks :)
Michel Pelletier
@michelp
good day, I'm working on a little side project to visualize graph traversal using adjacency matrix multiplication using GraphBLAS. What I was hoping for was a tip on how to put two plots side by side in toyplot. For example, here's a static image of the layout i'm looking for https://github.com/michelp/pggraphblas/raw/master/docs/AdjacencyMatrixBFS.svg?sanitize=true
The static image shows one "step" in a matrix x vector multiplication using a boolean semiring. In addition to discovering how to do that layout with toyplot (which looks very amazingly cool btw!) if anyone has a tip on how i can even possibly animate the process i do eventually hope to many that possible, but first things first, being able to layout a graph next to its adjacency matrix is my first step
I have the code that generates the graph and the matrix, i'm just not sure how to put them next to each other in the same cell (i'm using jupyter)
Michel Pelletier
@michelp
ah i think i answered my own question using Canvas layouts! thanks for the very cool library anyway :)
Timothy M. Shead
@tshead
Michel: glad you got it going, and thanks for the kind words 😊
Michel Pelletier
@michelp
I'm moving along pretty nicely with my project, but have run into one issue, is it possible to dynamically assign edge labels to a graph? On the examples at https://toyplot.readthedocs.io/en/stable/graph-visualization.html#edge-rendering all the edge labels are the same static value, but i'd like to assign my labels per edge to correspond to the value in the equivalent adjacency matrix cell.
Timothy M. Shead
@tshead
@michelp : it’s poorly tested, but you should be able to pass a sequence of markets to mmarkers.
Michel Pelletier
@michelp
ah ok, i guess that was the obvious thing i didn't try :)
matrixbot
@matrixbot
hannes i often want to use data from dictionaries with toyplot, eg .keys() as x and .items() as y axes. unfortunately this leads to "TypeError: float() argument must be a string or a number, not 'dict_keys'" from https://toyplot.readthedocs.io/en/stable/_modules/toyplot/require.html#scalar_array because numpy's conversion to an array does not like python's dict views or iterators
hannes i can wrap it into a list() call but that seems ugly
hannes no idea why numpy does not support those but i wonder if adding some logic to toyplot's scalar_array function would make sense for this usecase?
hannes ```
hannes Example of what I would love to use (in an explicite way):
import toyplot

data = {1: 5, 2: 3, 3: 4}

canvas = toyplot.Canvas()
axes = canvas.cartesian()

mark = axes.plot(
    data.keys(),
    data.values(),
)
Timothy M. Shead
@tshead
@matrixbot : I’d certainly accept a pull request to require.scalar_array() that handles a wider variety of sequences / iterators. Extra points if it isn’t a chain of isinstance calls … :)
matrixbot
@matrixbot
hannes :D
matrixbot
@matrixbot
hannes https://toyplot.readthedocs.io/en/stable/tutorial.html#scatterplots uses a shared x axis for a stacked plot, is there a way to make a "true" scatterplot of irregular data?
hannes i have unique x and y axes for each series
Timothy M. Shead
@tshead

@matrixbot : There is an implicit assumption with scatterplot() that your series are all the same length. When that isn’t the case, just make multiple calls to scatterplot() and you’ll get what you’re expecting.

Cheers,
Tim

egayer
@egayer
Hi all, new with toyplot and trying to figure out how I could use it with Spyder. Which render should I use ? thanks
matrixbot
@matrixbot
hannes it depends (tm)
hannes just use the default until it does not do what you need
egayer
@egayer
@matrixbot well, objects are created but nothing is displayed when using python inline backend or Qt5 backend.
Timothy M. Shead
@tshead
I’m unfamiliar with Spyder, but it looks like it has support for Jupyter notebooks. Try familiarizing yourself with Toyplot in a notebook.
matrixbot
@matrixbot
hannes egayer (Gitter): you can get a plot if you make the ipython console return your canvas object