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

jittering, offset/nudge, dodge #396

Closed
kanitw opened this issue Mar 21, 2015 · 21 comments
Closed

jittering, offset/nudge, dodge #396

kanitw opened this issue Mar 21, 2015 · 21 comments
Assignees
Labels
Area - Visual Encoding P2 Important Issues that should be fixed soon RFC / Discussion 💬 For discussing proposed changes

Comments

@kanitw
Copy link
Member

kanitw commented Mar 21, 2015

See http://docs.ggplot2.org/current/geom_jitter.html, http://docs.ggplot2.org/current/position_nudge.html, http://docs.ggplot2.org/current/position_dodge.html for example

@kanitw kanitw modified the milestone: 1.0 (Should Have Later) Apr 13, 2015
@kanitw kanitw modified the milestones: 1.0 (Should Have Later), Nice to have Apr 21, 2015
@kanitw kanitw added help wanted RFC / Discussion 💬 For discussing proposed changes labels Apr 22, 2015
@kanitw kanitw modified the milestones: Nice to have, x.x (Should Have Later) May 24, 2015
@kanitw kanitw modified the milestones: 0.9 Syntax Revision & Freeze, x.x (Should Have Later) Oct 22, 2015
@kanitw kanitw added Easy and removed Easy labels Nov 13, 2015
@kanitw kanitw modified the milestones: 0.9.x Syntax Revision & Freeze, x.x (Should Have Later) Nov 16, 2015
@kanitw kanitw modified the milestones: x.x (Should Have Later), 1.x Should have after 1.0 , x.x (Nice to Have) Dec 1, 2015
@kanitw
Copy link
Member Author

kanitw commented Feb 6, 2016

This would require a random transform in Vega (or at least access to random call in expression)

@kanitw kanitw changed the title jittering jittering, offset/nudge, dodge Oct 18, 2016
@kanitw kanitw added this to the 2.x Better Support for Annotation milestone Jan 24, 2018
@kanitw
Copy link
Member Author

kanitw commented Jan 28, 2018

A tricky questions is whether dx should share the scale with x (and the same for y) and if not, what should be the default scale.

Thinking of a few cases.

For dodge, this is basically having x-scale as a band scale and dx-scale as another band scale that has a range = [0, bandwidth of x scale]. (I don't think we have to care about preserve = "single" option in ggplot, it's a bad idea IMHO anyway)

For jitter, this is basically having x-scale as a point scale, and dx mapping a random value (say from [0,1]) to [0, bandwidth]. Another way to think is mapping random value from [0, bandwidth] with an identity scale (f(x) = x).

nudge is simply mapping fixed value to dx/dy. No scale needed!

For these examples, it seems like dx should have its own scale (not sharing with x).

However, if we think about stack offset example, we might still want the offset value to share the scale.
But that would make the scale domain a bit weird anyway, so it might be better to just have explicit stack transform and calculate the new x and x2 directly.

@kanitw
Copy link
Member Author

kanitw commented Jan 28, 2018

We probably have to think what's the right scale type and range for dx based on x's scale type

  • x = linear/time (Q/T),
    • dx is Q/T -- should dx be linear too? or just identity?
    • dx is N/O -- ???
  • x = non-linear (Q)
    • dx is Q/T -- what's the right thing to do? (I guess identity? -- although this won't make sense for the most case, we should still provide some okay-ish default)
    • dx is N/O -- ???
  • x = band/point --
    • dx is Q/T -- identity or linear (this is the jitter case like described above)
    • dx is N/O -- band or point (this is the dodge case like described above)

@kanitw
Copy link
Member Author

kanitw commented Jan 30, 2018

We will probably implement the mark definition support for now #3328.

Note that we can't call them dx and dy as dx and dy are offset for text marks that are applied before rotation (with angle) but the general offset would be applied after. So maybe offsetX/Y/X2/Y2 maybe better.

@kanitw
Copy link
Member Author

kanitw commented Feb 4, 2018

We are thinking that we will eventually support offsetX/Y/X2/Y2 as channels so it's something like this.

encoding: {
   x: {field: ...}
   offsetX:  ... field or value definition ...
} 

Another possible model is having offset nested under x/y/x2/y2 like in Vega:

encoding: {
   x: {
     field/value: ..., 
     ...,
     offset:  ... field or value definition ...
   }
} 

However, this model has a major flaw when using with condition, in the sense that we can no longer enforce that users can only map only one field to "offsetX" -- which will violate current architecture that only allows one field per channel (condition only support one field in their branch)

x: {
  condition: {
    field: …, type: …,
    offset: {
      condition: {test: …, field: 'a', type: ..., scale: ..., (no axis)},
      …
    }
  },
  value: …
  offset: {
    condition: {test: …, field: 'b', type: ..., scale: ..., (no axis)},
    …
  }
}

Plus, this look super messy.

@kanitw kanitw modified the milestones: 2.x Better Support for Annotation, 2.x Visual Encoding Patches Mar 4, 2018
@kanitw
Copy link
Member Author

kanitw commented May 31, 2018

The trickiest part of supporting this offset is how to make it work correctly with interval selection.

@domoritz
Copy link
Member

Can the x axis be discrete?

@kanitw
Copy link
Member Author

kanitw commented May 31, 2018

Yes. We need to think this through and prototype different cases. Probably wont get to do that until my thesis is stable lol

@kanitw
Copy link
Member Author

kanitw commented Jul 29, 2018

vega/altair#1055 is another use case where offset is useful as an encoding channel so we can do conditional offset.

@kanitw
Copy link
Member Author

kanitw commented Feb 25, 2019

I think this is one of a few things that I want to tackle in the next 1-2 months, given group bar is a quite common use case and we don't do it that well yet.

@kanitw kanitw added P2 Important Issues that should be fixed soon RFC / Discussion 💬 For discussing proposed changes and removed 🙋‍♀️ Feature Request labels Feb 25, 2019
@kanitw
Copy link
Member Author

kanitw commented Mar 10, 2019

I'm creating #4703 to propose x/yOffset channel as a solution to this. (This issue is getting too long, so I'm closing it. Let's discuss more in #4703).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area - Visual Encoding P2 Important Issues that should be fixed soon RFC / Discussion 💬 For discussing proposed changes
Projects
None yet
Development

No branches or pull requests

5 participants