Skip to content

Joyplot Doc #1090

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
wants to merge 2 commits into from
Closed

Joyplot Doc #1090

wants to merge 2 commits into from

Conversation

Kully
Copy link
Contributor

@Kully Kully commented Sep 14, 2018

for Issue: #1018

@Kully
Copy link
Contributor Author

Kully commented Sep 17, 2018

Not having luck with violin plots...I am going to try building from scratch. Could be a fun FF.

@nicolaskruchten
Copy link
Contributor

what's not working with violin plots? Groups as 'y', orientation='h', make them half...

@nicolaskruchten
Copy link
Contributor

image

@Kully
Copy link
Contributor Author

Kully commented Sep 17, 2018

Groups as 'y', orientation='h', make them half...

I'm having trouble allowing them to overlap. violingap doesn't do the trick.

@nicolaskruchten
Copy link
Contributor

Right, they won't overlap... We could just generalize violin to allow it, rather than wrap a whole subplot-based infrastructure onto it... @etpinard ?

@Kully
Copy link
Contributor Author

Kully commented Sep 17, 2018

We could just generalize violin to allow it

I'd like to take a first stab at adding that feature if we decide to go that route

@Kully Kully self-assigned this Oct 9, 2018
@Kully
Copy link
Contributor Author

Kully commented Oct 10, 2018

Continuing off @nicolaskruchten 's point, the violins will not be able to overlap because violingap is only allowed in the closed interval [0, 1].


If we place violins at y=0, 0.2, and 0.6 and violingap=0

newplot

Nudging the 0.6 violin very close to 0.2 (0.21) violingap=0 still, we get:

newplot 1


If we allowed negative numbers for violingap this solves the problem.

Setting violingap=-1 (actually setting groupFraction to 2 in the src code: see this line)and returning the 3rd violin to its original y values we get:

newplot 2


There is an issue of the violins getting cut off by the frame, but we can fix this.

CODE FOR EXAMPLE:

var data = [
{
  type: 'violin',
  x: [0, 5, 7, 8],
  points: 'none',
  box: {
    visible: false
  },
  boxpoints: false,
  line: {
    color: 'black'
  },
  fillcolor: '#8dd3c7',
  opacity: 0.6,
  meanline: {
    visible: false
  },
  y0: 0
},
{
  type: 'violin',
  x: [0, 4, 7, 8],
  points: 'none',
  box: {
    visible: false
  },
  boxpoints: false,
  line: {
    color: 'black'
  },
  fillcolor: '#d3c78d',
  opacity: 0.6,
  meanline: {
    visible: false
  },
  y0: 0.2
},
{
  type: 'violin',
  x: [0, 4, 7, 8],
  points: 'none',
  box: {
    visible: false
  },
  boxpoints: false,
  line: {
    color: 'black'
  },
  fillcolor: '#c78dd3',
  opacity: 0.6,
  meanline: {
    visible: false
  },
  y0: 0.21
}
];

var layout = {
  title: "Basic Horizontal Violin Plot",
  xaxis: {
    zeroline: false
  },
  violingap: 0
};

Plotly.newPlot('graph', data, layout);

@etpinard WDYT of this approach?

@etpinard
Copy link
Contributor

Ok, and what's wrong again with something like: https://codepen.io/etpinard/pen/VGOQad?editors=1010

@Kully
Copy link
Contributor Author

Kully commented Oct 10, 2018

Ok, and what's wrong again with something like

I should have made them half violins to demonstrate the point more clearly. In the example you shared, I want to take the top blue one for example and shift it down a few pixels so that its middle line is somewhere between 1 and 2, while leaving the rest looking the same.

@etpinard
Copy link
Contributor

or example and shift it down a few pixels so that its middle line is somewhere between 1 and 2, while leaving the rest looking the same.

tweaking the y coordinates should do the trick, no?

@Kully
Copy link
Contributor Author

Kully commented Oct 11, 2018

tweaking the y coordinates should do the trick, no?

I swapped all the y values of orange violin at 2 to 1.8 and get this: https://codepen.io/plotly/pen/yRXjPe

Can you see how the violins are now all thinner and I was not able to just shove that one violin down by a certain number of pixels?

@etpinard
Copy link
Contributor

Thanks for codePen @Kully !

Would something like https://codepen.io/etpinard/pen/yRogaq be ok?

If not, we could add a width attribute for violin (and box) traces that would essentially override the internal dPos parameter. This new attribute would be similar to width in bar traces.

Allowing violingap and violingroupgap to be negative would work, as these attributes affect the violins' width, but I don't see how we can justify making a "gap" value negative. The "real" parameter we want to override here is the violin width, not the gaps between them.

@Kully
Copy link
Contributor Author

Kully commented Oct 12, 2018

f not, we could add a width attribute for violin (and box) traces that would essentially override the internal dPos parameter.

I like this idea.

@nicolaskruchten
Copy link
Contributor

vote to close... will be covered in the v4 docs

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

Successfully merging this pull request may close these issues.

4 participants