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

[WIP] Carpet plots #1239

Closed
wants to merge 143 commits into from
Closed

[WIP] Carpet plots #1239

wants to merge 143 commits into from

Conversation

rreusser
Copy link
Contributor

@rreusser rreusser commented Dec 8, 2016

Trace types to be implemented:

  • trace type: carpet
    • x-cheater
    • y-cheater
    • first cut
    • setconvert
      • linear interpolation
      • bicubic interpolation
      • derivatives
      • fix clipping and detection of out-of-range points
    • attrs to style the axes (implemented but needs feedback)
    • array tickmode label formatting
    • linear tickmode label formatting
    • graceful degradation when bad data is provided
    • play with with cartesian axes/subplots
    • hide cheater axis by default (if no other no-cheater traces visible on that axis)
    • construct clip shape around the axis edge
    • fix (disable?) hover
    • fix missing minor gridline on tickmode: 'array' axes
    • image tests
    • good jasmine coverage
  • trace type: scattercarpet
    • attributes
    • supply defaults
    • basic functionality
    • clip to axis bounds
    • fix hover
    • jasmine tests
    • image tests
    • break any connections with and filter invalid points
  • trace type: contourcarpet
    • clip to axis bounds
    • attributes
    • supply defaults
    • clean data
    • contour lines
    • filled contour inequalities
    • filled contours
    • jasmine tests
    • image tests
    • fix fully-filled area bug (one side is closed but doesn't follow the edge
    • legend symbols
    • maybe constraints follow non-colorscale syntax?
    • label inequalities on the plot
    • assign to correct subplot based on carpetid (must currently/redundantly be specified separately)

Current state:

screen shot 2016-12-08 at 08 08 19

Live version: https://rreusser.github.io/demos/plotly-unsupported/carpet.html

Sorry, something went wrong.

@rreusser
Copy link
Contributor Author

rreusser commented Dec 8, 2016

Interesting question, @etpinard @alexcjohnson:

If we allow scatter plots and inequality contours, I'm not sure, generally speaking that we can guarantee points will lie on the correct side of the inequality. That is, bicubic interpolation of the data value at every point along the contour won't actually equal the contour value. Splines handle affine transforms nicely, but if the grid lines themselves are cubic splines, then the true contour lines that cut across those grid lines subject to bicubic interpolation would be more complicated than cubic splines themselves and could probably only be drawn correctly by oversampling.

I'm glad to clarify that if needed, but just something I'm realizing as I go through this. That was part of the initial motivation for a high resolution grid. We could subdivide to reduce the problem, but I'm not yet sure what the best option will be. Or this could just not be a concern since you shouldn't really be relying upon that to make any judgments in the first place.

(NURBS might be sufficient, but I think you just have to solve it numerically anyway and that would still just have to be drawn by subdividing)

@alexcjohnson
Copy link
Collaborator

When you say "the true contour" are you referring to the exact path the contour takes within one grid cell being different if you draw it in a,b space and map back to x,y vs if you drew it in x,y space in the first place? I'm actually not sure if there is an objectively true contour in that sense... in fact if you've chosen a really good carpet transformation, the contours you draw in x,y space might even be more meaningful at sub-cell resolution than in a,b space because the variation of physically relevant properties might be more homogeneous than in a,b space (where they could be stretched along a diagonal for example).

Also what do you mean by "high-resolution grid" - isn't the grid just whatever data we get from the user?

@rreusser
Copy link
Contributor Author

rreusser commented Dec 9, 2016

Conclusion after talking with @alexcjohnson: The actual real-world implications of this and the cost of doing better (i.e. numerical spline-fitting) make it negligible for now as long as it's documented as such.

Copy link
Contributor

@etpinard etpinard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass review.

I made a few recommendations but I didn't catch any red flags. Amazing work @rreusser 🎉


'use strict';

module.exports = require('../src/traces/carpet');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. This file doesn't do anything, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it shouldn't be included by default, but see:

require('./contourcarpet'),

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right lib/carpet.js is required, but src/lib/carpet.js isn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visible: {
valType: 'boolean',
role: 'info',
description: [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could reuse the declaration from cartesian/ with visible: axesAttrs.visible,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I blindly copied this definition in a rush since it broke gl3d plots entirely until it was present.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// there's anything to sort:
hasPriorities = hasPriorities || priority;

prioritizedFullDataLookup.push({index: i, priority: priority});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, we need this after all? I thought we concluded it wasn't necessary at some point in #plotly_js. Honesty, it doesn't add much code, so I'm 👍 either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question… I thought the same, but there it is. I'll check on the removability.

Copy link
Contributor Author

@rreusser rreusser Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverting this. I reordered one of the mocks to ensure that data is in an order that would cause it to fail if this were required but not implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var colorAttrs = require('../../components/color/attributes');

module.exports = {
carpetid: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id isn't the most plotly-esque of identifiers. It's probably the best for this job though. But perhaps, carpetname or simply carpet would sound more familiar to plotly users?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

carpet works for me. Should an easy change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valType: 'number',
dflt: 1,
min: 0,
max: 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice to make this consistent with the scatter definition of smoothing where the default value is 1 and the max 1.3.

});
}

/* function clipGaps(plotGroup, plotinfo, cd0, perimeter) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO or 🔪

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. TODO. I'll remove it. It's in the git history or just copied from contour anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.call(Drawing.lineGroupStyle,
line.width,
line.color,
// contours.coloring === 'lines' ? colorMap(start + i * cs) : line.color,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo or 🔪


ScatterCarpet.attributes = require('./attributes');
ScatterCarpet.supplyDefaults = require('./defaults');
// ScatterCarpet.colorbar = require('../scatter/colorbar');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess should just work as scattercarpet is using the same colorscale attribute as the cartesian version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. Uncommented. ✅

var scatterSelect = require('../scatter/select');


module.exports = function selectPoints(searchInfo, polygon) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, why not? Does this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appears so! 🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var scatterStyle = require('../scatter/style');


module.exports = function style(gd) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module isn't registered in scattercarpet/index.js. TODO or 🔪 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've included it and restored the same check that scatterternary uses to either run it or take for granted that the scatter trace has already run it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rreusser
Copy link
Contributor Author

rreusser commented Apr 12, 2017

Ah, I see. My confusion. 👍 (Edit: oh yeah… that's the main entry point… removing it makes everything fail… gotcha)

@rreusser rreusser mentioned this pull request Apr 13, 2017
@rreusser
Copy link
Contributor Author

Superseded by #1595.

@rreusser rreusser closed this Apr 13, 2017
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

Successfully merging this pull request may close these issues.

None yet

4 participants