-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
transparent option for rasterize? #2487
Comments
Same here, is there an option to set the gray to transparent? |
|
A transparent background is actually the default when using GeoViews, i.e. if you were to switch to To override the default NaN color to be transparent you can set |
I would think that the default should be transparent whether or not using GeoViews; is there a reason it shouldn't be? Transparent allows grid lines, etc. to show through, which can indicate missing values much better than any single color can even when there isn't an underlying map to let show through. |
Makes sense.
I'm fine with that. No need to change the defaults as long as it is properly documented. 👍 |
Cool. This works: %%opts Image [colorbar=True clipping_colors={'NaN': (0, 0, 0, 0)}] (cmap=palettable.cubehelix.perceptual_rainbow_16.mpl_colormap)
%opts WMTS [width=700 height=400]
tiles = gv.WMTS('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.jpg')
points = gv.operation.project_points(gv.Points(verts, vdims=['z']))
tiles * rasterize(hv.TriMesh((tris, points)), aggregator=ds.mean('z'), precompute=True ) Thanks guys! |
Ooh; pretty!
There's probably some example that would make this clearer to me, but I can't quite appreciate how a grey default color allows us to "see the nan values" in a way that actual transparency does not. And I very much do see how using transparency would be useful by default, to allow images to have a non-rectangular shape. Some good counterexamples could convince me, but I'm definitely still feeling that NaN should be transparent by default. In any case, can we make it simpler to set this option by defining a special |
I agree with both these ideas:
|
@jbednar You are usually the first person to point out that a white background and Definite +1 from me on aliasing 'transparent' to |
Sigh; you're right. Using a gray background like mpl used to do would alleviate that issue, but it makes for ugly plots and reduces the dynamic range available when plotting lines and points, so that's a non-starter. Plus some important colormaps (greys!) include grey as a value. So many considerations to try to balance against each other! Given that the default background is white and that many, many people will use white backgrounds, probably the safest thing is just to make sure that none of our default or generally suggested colormaps include white. People can explicitly choose something like "fire" if they want to have the maximum dynamic range, but it's probably better to prioritize avoiding misleading plots if there might be missing values. Viridis doesn't actually include white, so there's no issue there. "Hot" and "fire" (colorcet linear_kryw_0_100_c71) do include white, but colorcet actually has one just like fire but without white (or pure black), namely linear_kry_5_98_c75: Given that HoloViews hasn't actually switched the default colormap away from "hot" yet, I'd argue that "fire" maybe isn't as good a default as this other one, for the reasons you outline. We'd need a name for this slightly muted version of fire, if we use it as a default. I guess Jean-Luc's suggestion "ember" is still available, as we never used that? In any case, viridis, fire, and ember (if we went with that name), as well as plasma, inferno, magma, and cvidis from matplotlib all are already incompatible with white backgrounds; each of them map increasing values to colors more and more perceptually similar to white: Specifically, all of them have luminance increasing over the colormaps, using white or yellow for the highest values. So none of them are appropriate as a default colormap if any of the underlying white background is allowed to show through. I think that the final conclusion is that any such default ought to be the "reversed" versions of one of those colormaps, starting from a value similar to (but distinguishable from) white, and becoming less and less like white as the values increase. So, "ember_r" as a default in holoviews 2.0? One downside is that it's a perceptually quite obvious breaking change from holoviews 1.x, given that "ember_r" is qualitatively the reverse of "hot", but I don't really see a way around that. Another downside is that "fire" and "ember" have a very natural interpretation as "intensity (of heat)" increasing from a black background, and much less so when increasing from a white background, but again I don't see any way around that given that people want a white background by default. In any case, continuing to use a default colormap that is incompatible with a white background, when white backgrounds are the default, seems untenable. |
In any case, @philippjfr, I do still think that NaN ought to be transparent by default. So I'm happy for you to make that change in #2483. As soon as you do, though, it becomes even more urgent to change the default colormap away from "hot", which then becomes even worse as a default than it was before. |
Okay |
Great, thanks! |
All sounds good to me though is there a shorter word we could use than |
I think |
Any harm in supporting both aliases? Then users can decide whether the short name is fine or not. That said, generally I don't like aliases so I think if we have to pick one, my vote is for |
Personally, I don't care about shorter in this case, I care about clearer, and |
I don't agree, that is totally obvious as an RGBA tuple with zero alpha. The tuple is totally unambiguous unlike any string name. Also, in general image processing |
In other words, I would be inclined to use |
Does that matter? Any RGB value with zero alpha should render identically, and 'transparent' makes no claim about the color just that it renders as transparent. |
I think the key here is your phrase "as an RGBA tuple". Yes, (0,0,0,0) is obvious as an RGBA tuple. But that's not the context here; what the user sees is |
That pixel yes. But neighboring pixels with non-zero alpha can be tainted by the R,G and B components if resampling. I don't think this problem crops up with anything we do right now but this it generally known that for image processing, the color channel matter even if the alpha channel is zero. I'm not convinced this case is worth adding an alias for so I am happy that this name is only currently processed in the context of Anyway, I can see that I will be overruled on this issue and I don't feel strongly enough about it that I would reject a PR because it includes this alias. |
The PR has now been merged. |
Bokeh has now added |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When I use
datashade
I get the transparent background that lets me see the WMTS tilesbut when I use
rasterize
, I get grey instead of transparentand I can't figure out how to fix it.
I did try to figure this out by googling and looking in docs and code, but failed... 😞
The text was updated successfully, but these errors were encountered: