Skip to content
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

Use new multistop gradients for continuous colorbars #2910

Merged
merged 3 commits into from
Aug 16, 2018

Conversation

alexcjohnson
Copy link
Collaborator

Avoids using lots of little rectangles for continuous colorscales, which was causing small colorbars to draw outside their boundaries due to some annoying and probably still wrong logic where we expand them a little in order to ensure overlaps so we don't see gaps due to antialiasing, so now I think we really can close #970. And yes github, I mean it this time.

I also fixed the original problem of slightly overflowing colorbars, but now that we're not using this for continuous colorscales it would only arise if you were to create a contour plot with very dense contours, particularly if you don't show the contour lines at all, only fills. Anyway there are other benefits to using a gradient:

  • better performance (we have one node with a gradient fill instead of 253 slightly-overlapping solid-fill nodes)
  • more accurate (the rounding and expansion was shifting the colors a little bit - this is part of why some baseline images changed, though some had the overflow issue)
  • in principle supports colorscales with opacity, though I haven't tested this, since we're not overlapping. That said we still wouldn't be able to do contour colorscales with opacity and no line, as that case still relies on overlaps. However I think in principle we could create a gradient for that case as well (using two very close stops to abruptly shift from one color to the next) in which case even that one could support opacity.

cc @etpinard

even though it's hard to actually trigger it now that we're using
gradients for continuous colorscales (would require a very dense
contour set colored by fills)
@etpinard
Copy link
Contributor

Nice PR 💃

Good to know also that SVG <linearGradient> are supported all the way to IE9

image

https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient

... so this shouldn't break anyone's graphs.

@alexcjohnson alexcjohnson merged commit fe709d0 into master Aug 16, 2018
@alexcjohnson alexcjohnson deleted the gradient-colorbar branch August 16, 2018 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

colorbar draws outside the bounds
2 participants