-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
Thanks a lot, this looks pretty nice already! I think there is no need to have the legend drawn automatically in Btw, a couple of practical things to add docs to gallery.jl:
|
# -------------- Some helpful types -------------- | ||
# ------------------------------------------------ | ||
|
||
# ╔═╡ bbffd9ac-70e8-49bd-83ed-7d79cf836596 |
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 guess these comes from developing in Pluto? I think both these and the begin .. end
blocks should be removed.
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.
Here and below also the indentation seems a bit off, should be 4 spaces.
tbl2 = (x = [1:N; 1:N; 1:N; 1:N], | ||
zz = [fill(2, N); fill(-2, N); fill(2.5, N); fill(0, N)], | ||
y = [2 .+ cumsum(randn(N)); -2 .+ cumsum(randn(N)); 2.5 .+ cumsum(randn(N)); cumsum(randn(N))], | ||
grp1 = [fill("a", 2N); fill("b", 2N)], |
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.
Indentation.
end | ||
|
||
# ╔═╡ 2bcbfb12-47e5-471a-b78f-4dfedaae3a0d | ||
function _legend(P, attribute, scale::ContinuousScale, title) |
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.
Can this have a more descriptive name? Otherwise the code is a bit difficult to follow with the various Legend
, _Legend_
and _legend
.
I also suspect that one should reconsider the type hierarchy a bit, in that rather than the Label
and KW
type, it may be easier to organize things as
struct SubLegendEntry
label::String
attributes::Dict{Symbol, Any} # when we "consolidate", it will be more than one pair
end
struct SubLegend
title::String
P::PlotFunc
entries::Vector{SubLegendEntry}
end
So that _legend
would just be a sublegend
function to return the SubLegend
object relative to some attribute.
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.
Having a custom SubLegend
type would make it cleaner to define the various consolidation approaches. There should probably be a merge!(sublegend1::SubLegend, sublegend2::SubLegend)
method that checks that the title is the same and merges the attribute for matching entries.
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.
(Thinking more carefully, scratch the above type hierarchy, I try to explain my idea more clearly in #32 (comment).)
grps1 = StructArrays.finduniquesorted(groupby1) | ||
|
||
out1 = map(grps1) do (grp, inds) | ||
@unpack label_kw = out[inds] |
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.
A minor point, but it seems to me that @unpack
is used too little to justify the extra dependency (even though a very light one).
Thanks for adding the consolidation bit. I've left some comments. Other than some formatting nitpicking, I think the main point is to have a clean structure for struct SubLegendEntry
label::String
visuals::Vector{Visual} # each plottype has its own attributes
end
struct SubLegend
title::String
entries::Vector{SubLegendEntry}
end We should make sure that this allow for a Then, consolidation becomes much easier using dicts (well, an sublegend_dict = LittleDict{String, SubLegend}()
for sublegend in sublegends
key = sublegend.title
current = get!(sublegend_dict, key, Sublegend(key, SubLegendEntry[]))
merge!(current, sublegend)
end |
Hi, I'll probably take a few days do address all this. I wanted to push a working version before the weekend. |
@greimel , just a heads up that I'm about to do some Do you have some local changes you'd like to push or can I go ahead and merge this version? |
hi @piever, sorry that this has stalled a bit. I've not worked on this in the meantime, I was busier than I thought with other things. Despite the messy state it should be fine to merge. If necessary I will help cleaning this up later. |
also feel free to commit the suggested changes. |
Todo
support Colorbar(future PR)automatically add legend when callingdraw(...)
(do you want that @piever?)