Skip to content

Support for raster graphics #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cpsievert opened this issue Mar 14, 2016 · 13 comments
Closed

Support for raster graphics #332

cpsievert opened this issue Mar 14, 2016 · 13 comments
Labels
feature something new

Comments

@cpsievert
Copy link

To support something like annotation_raster() in our R package, which would lead to awesomeness such as conversion of ggmap (people have been asking for this for a long time), I need support for displaying a matrix of arbitrary color codes. Using a heatmap seems out of the question since we can't generate a sensible colorscale, and drawing a marker for each cell seems inefficient. Any thoughts on how to approach this?

@mdtusz
Copy link
Contributor

mdtusz commented Mar 15, 2016

As far as I can tell, this would be fairly straightforward as far as the actual graphics part goes. The interface and having things play nicely with axes, ranges etc. might be trickier just because of the structure and codepaths that exist as of now.

Adding a canvas layer for images or raw raster data would be a fairly efficient draw provided the data doesn't require much processing, but I can't really think of any intensive processing that would slow down a draw.

@mdtusz mdtusz added the feature something new label Mar 15, 2016
@jackparmer
Copy link
Contributor

Seems like this would be a great way to make geographic contour maps like this too:

image
(via PlanetOS, http://data.planetos.com/datasets/noaa_gfs_global_sflux_0.12d:gfs-global-weather-forecast-by-ncep-near-surface-parameters)

Plotly user ToniBois has been making some incredible geographic contour maps / weather maps in Plotly:

image

https://plot.ly/~ToniBois/

But they would be unpractically slow to load for most users compared to the PlanetOS ones. It would be awesome to provide fast, interactive weather maps to Plotly's users, but I don't know whether this or the contourgl/heatmapgl projects are better bets. @etpinard @monfera ?

@jackparmer
Copy link
Contributor

Another great weather map example from NREL. Could be incredible as an interactive:

image

@mdtusz
Copy link
Contributor

mdtusz commented Jun 3, 2016

Not sure if things like ⬆️ fit in best with a raster type - they're much more applicable as contours/heatmaps in my mind.

For raster data however (that is, values consistent/regular in their distribution across a width and height) we should be able to handle up to ~4 megapixels before it becomes too slow.

http://jsbin.com/vuzipisema/1/edit?js,output

You can safely increase the width/height on that to 2000 and 2000 before it starts to be really slow.

@monfera
Copy link
Contributor

monfera commented Jun 3, 2016

Yes as both of you guys say a contour plot would be a first candidate.

@garyfeng
Copy link

garyfeng commented Jun 28, 2016

I see "raster image support coming up soon" referenced in the current code. Wondering how soon and how to contribute.

I need a transparent background image for a heatmap plot. Have been hacking the SVG output to insert an image layer, see
https://gist.github.com/garyfeng/9516714839c84a1982dda74dd5f14a6c. Unless there is a master plan, I will probably go into the heatmap code and add a background parameter to the SVG output. Would like to know who else might be working on this and whether there is a better way.

@mdtusz
Copy link
Contributor

mdtusz commented Jun 28, 2016

The raster type will likely be used more for raw raster data rather than images - you can add images however using layout.images and setting the xref and yref to”” the respective axes. Note however that the image will be distorted when the plot bounds are changed (i.e. when zoomed).

@ssfrr
Copy link

ssfrr commented Dec 7, 2016

I just wanted to plug my use-case for visualizing matrices as raster plots. I do audio DSP research using Jupyter and spend a lot of time looking at spectrograms like this:

image

I've been using heatmap, but they really slow down my notebooks compared to something like matplotlib that generates and displays a png.

@cpsievert
Copy link
Author

I think this can be closed now? Thanks to layout.images we can fully support annotation_raster() in the R package.

https://cpsievert.github.io/plotcon17/workshop/day1/#45

@ssfrr
Copy link

ssfrr commented May 11, 2017

I'm still hoping for support for raw raster data, e.g. if I have a 2D matrix of floats I want to visualize them as a colorscaled grid with axes. Most of my data are not huge (~1000x1000) but visualizing them as a heatmap slows down my notebooks quite a bit. Is there a better way to do this? (using the javascript API)

@jackparmer
Copy link
Contributor

@ssfr have you tried using heatmapgl (the webgl version of plotly heatmaps)? Here's an example in Python:
https://plot.ly/python/heatmap-webgl/

@ssfrr
Copy link

ssfrr commented Jun 28, 2017

@jackparmer strangely the GL versions seems to perform about the same, maybe worse. I'm going to a little digging to see where the issues are.

@jackparmer
Copy link
Contributor

Thanks @ssfrr . If you have a link to a chart (both an SVG and GL version), that would help to debug. Here's a link to a GL audio spectrogram for example: https://plot.ly/~PythonPlotBot/829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

No branches or pull requests

6 participants