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

possible to display 2 groups of data with different number of points with violinplot? #53

Closed
NicolasClairis opened this issue Jun 27, 2022 · 2 comments

Comments

@NicolasClairis
Copy link
Contributor

Thanks a lot for this great function!
I have an issue as I want to use violinplot to display two groups of data (let's call them vectors A and B) that have unequal number of datapoints (n=24 and n=23). Because of this, the call to the script (violinplot([A,B],{'A','B'})) doesn't work with the following error message "Error using vertcat: Dimensions of arrays being concatenated are not consistent."
I thought that the best would be to enter the data in 2 steps with one call to violinplot for each dataset, however, since there is nowhere to specify the X coordinates, it doesn't seem possible. Would you have some recommendation about how to do? I guess one should go to use violin directly but would it be possible to add the possibility to specify the X coordinates within violinplot?

@mikelgg93
Copy link
Collaborator

Hi @NicolasClairis
If you just want to plot two violins with unequal data sizes, that should work by default.

If what you want to do is to compare these violinplots, i.e. plot them side by side, my recommendation would be to call directly to Violin.m skipping the violinplot.m function. Please, check the readme file, on how to call the violin function directly or check this issue #49 (comment) where this is already described.

@NicolasClairis
Copy link
Contributor Author

Dear @mikelgg93 thanks a lot for the very fast answer! I digged a bit in the previous issues but missed this one apparently so thanks for pointing it!
I just figured it out after a bit of struggling indeed. In the end I just replaced
violinplot([A,B],['A_name','B_name'})
by the following code:
violin({A},1); violin({B},2); xticks(1:2); xticklabels({'A_name','B_name'});
it's a bit longer but it seems to work. If this could be implemented directly within violinplot that would be quite practical though but anyway, I'm happy it works with not so much trouble in the end!

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

No branches or pull requests

2 participants