-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
src/silhouetteplot.jl
Outdated
|
||
# Settings for the axes | ||
legend --> false | ||
yflip := true |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/silhouetteplot.jl
Outdated
plt = plot([],label="") | ||
for i in 1:k | ||
idx = (a.==i) # members of cluster i | ||
si = sort(s[idx],rev=true) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does fillto
work horizontally?
Can I get an update on the changes requested to this PR? |
@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. |
14e6985
to
474165c
Compare
Updated the example in documentation string and the README. |
This goes to address issue #268.