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

fix order for Geom.violin #1079

Closed
IgorDouven opened this issue Dec 30, 2017 · 3 comments · Fixed by #1095
Closed

fix order for Geom.violin #1079

IgorDouven opened this issue Dec 30, 2017 · 3 comments · Fixed by #1095

Comments

@IgorDouven
Copy link

I'm trying to create a violin plot from a DataFrame, with x=Col.index and y=Col.value. It works fine, except that the order of the columns is not preserved in the plot. Is there a way to fix the order? Thanks in advance!

@IgorDouven
Copy link
Author

Adding Scale.x_discrete(levels=df.colindex.names) did the trick, where df is the name of the DataFrame I'm plotting. Might be good to have a bit more about this in the documentation.

@tlnagy
Copy link
Member

tlnagy commented Jan 5, 2018

We would be glad to merge a PR if you want to add an example to the docs!

@IgorDouven
Copy link
Author

IgorDouven commented Jan 7, 2018

I'd be happy to do that, but I'm completely new to GitHub. Could someone else add the example below to the page http://gadflyjl.org/stable/lib/scales/scale_x_discrete.html#Scale.x_discrete-1?

# When plotting a DataFrame, preserve the order of the columns in the plot:

using DataFrames
df = DataFrame(v1 = randn(10), v2 = randn(10), v3 = randn(10))
plot(df, x=Col.index, y=Col.value, Scale.x_discrete(levels=df.colindex.names))

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 a pull request may close this issue.

2 participants