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

Added silhouette plot #269

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

tobydriscoll
Copy link

This goes to address issue #268.

Copy link
Member

@mkborregaard mkborregaard left a comment

Choose a reason for hiding this comment

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

Thanks, this looks nice. I've a few questions.


# Settings for the axes
legend --> false
yflip := true
Copy link
Member

Choose a reason for hiding this comment

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

Why do you override settings for these three attributes? Might --> not be better?

Copy link
Author

Choose a reason for hiding this comment

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

yflip needs to be known in order to get the sorting order right. I'm not sure how to read that attribute if it wasn't set explicitly, and I thought top-to-bottom was most natural.

xlims and yticks should probably be "soft" assignments, I agree. Will modify.

Copy link
Author

Choose a reason for hiding this comment

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

Actually, I've learned that if I don't assign yticks:=, the labels don't get preserved. I'd really rather show the size of each cluster than the cumulative sizes. Do you know a fix?

Copy link
Member

Choose a reason for hiding this comment

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

You can get the value by plotattributes[:yticks], I think. You can also read it, and then explicitly assign what you read to it.

Copy link
Author

Choose a reason for hiding this comment

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

No, if I try to reference plotattributes[:yticks] when it was left unset in the invoking plot command, I get a "key not found" error. I suppose that unset attributes aren't given values until later in the pipeline.

Copy link
Author

Choose a reason for hiding this comment

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

I've just avoided the issue by making yflip a keyword setting in silhouetteplot. It's true by default, but setting it to false is respected.

plt = plot([],label="")
for i in 1:k
idx = (a.==i) # members of cluster i
si = sort(s[idx],rev=true)
Copy link
Member

Choose a reason for hiding this comment

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

better to use filter here which avoids allocating the temporary idx array

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, I don't know how that works when the filtered array is not the one on which the selection is predicated. It's a boolean vector, so it's probably not creating a big performance issue.

si = sort(s[idx],rev=true)
@series begin
linealpha --> 0
seriestype := :shape
Copy link
Member

Choose a reason for hiding this comment

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

why do you use shape? I think just a line with a fillto argument might be simpler (try to run plot(sort(randn(1000)), fillto = 0) to see the effect) and easier?

Copy link
Author

Choose a reason for hiding this comment

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

Does fillto work horizontally?

src/silhouetteplot.jl Outdated Show resolved Hide resolved
src/silhouetteplot.jl Outdated Show resolved Hide resolved
tobydriscoll added a commit to tobydriscoll/StatsPlots.jl that referenced this pull request Nov 19, 2019
Project.toml Outdated Show resolved Hide resolved
@tobydriscoll
Copy link
Author

Can I get an update on the changes requested to this PR?

@mkborregaard
Copy link
Member

@tobydriscoll really sorry for the ridiculously late response here. Could you rebase this onto master resolving the conflicts, and add an example to the Readme documenting the use of this function? Then I'll merge. Thanks, and sorry again.

@tobydriscoll
Copy link
Author

Updated the example in documentation string and the README.

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.

3 participants