-
-
Notifications
You must be signed in to change notification settings - Fork 404
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 Labels element #2352
Added Labels element #2352
Conversation
I realize this is still WIP but just as a reminder, I would use this PR to add a warning to |
0cab29e
to
54e6fe4
Compare
54e6fe4
to
32575d3
Compare
32575d3
to
71e1a4d
Compare
I don't necessarily think we have to deprecate |
The new docs for Labels make it clear how Labels has uses beyond what is supported for Text. If Text has uses not well supported by Labels, presumably that should be made clear now in the docs for Text? |
Really a matter of convenience, if you want a single label: |
Ready to review/merge. |
"\n", | ||
"**Dependencies**: Bokeh\n", | ||
"\n", | ||
"**Backends**: [Bokeh](./Labels.ipynb), [Matplotlib]('../matplotlib/Labels.ipynb')" |
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.
Please use the table that is consistent with all the other element notebooks...
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.
That does not format nicely in JupyterLab, all notebooks should be converted to this format. It looks nicer too and gets rid of all the horrible HTML.
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.
In that case it should be fixed in a separate PR. Not by mixing different markup.
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 used the new format in all the recently added elements, no point reverting those. Happy to follow up this PR by updating all existing reference notebooks (although that should probably wait until your metadata PR is merged).
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.
Ok. Sounds good.
holoviews/element/annotation.py
Outdated
""" | ||
Labels represents a collection of text labels associated with 2D | ||
coordinates. Unlike other Annotation types it is vectorized to | ||
draw labels from a dataset. |
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.
It isn't really an annotation type given that it inherits from chart.Points
.
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.
True although that's mostly an implementation detail, I can probably get it to inherit from Dataset and Annotation instead.
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.
Nevermind, not a good idea due to the custom Annotation.clone
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.
Still shouldn't inherit from Points though.
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'm not suggesting changing the implementation, just fixing the docstring. Frankly, I see this kind of element as being halfway between a chart and an annotation type.
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.
Still shouldn't inherit from Points though.
Agreed. But I assume it will have to inherit from some sort of Chart
.
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.
Dataset
+ Element2D
is the standard inheritance for something like this. At some point we should probably revisit these baseclasses, e.g. I think Scatter should be a Chart type for instance while Points shouldn't. In my mind Chart describes the 0-1D case of independent vs. dependent dimensions (e.g. Scatter, Curve, Area, Bars etc.), while we've never come up with a baseclass for the 2D space concept that encompasses Points, Path, VectorField etc.
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.
Makes sense - maybe it could be called Chart2D
or something. Anyway, I suggest filing an issue with this suggestion if there isn't one already.
Implementation looks fine other than few comments I've made above. I still think having so many uses of the word |
7125025
to
d93cf47
Compare
Ready to merge. |
Looks good. Merging. |
It seems like it would be confusing and ambiguous if hv.Labels() accepted that same signature? If so, then should hv.Text(*a) just become a macro that returns hv.Labels([*a])? I guess the main implication of that would be for options, which would then need to be set on Labels instead of Text. Hmm. |
We do have a mechanism for this which is an operation+Compositor, which would look something like this: class text_to_labels(operation):
def _process(self, element, key=None):
params = hv.util.get_param_values(element)
return Labels([(element.x, element.y, element.text)], **params)
Compositor.register(Compositor("Text", text_to_labels, None,
'data', transfer_options=True,
transfer_parameters=True,
output_type=Labels)) |
@philippjfr, that sounds like a reasonable approach. hv.Text can then be introduced as a simple convenience wrapper for Labels... |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Adds a Labels element type for vectorized drawing of labels and text. Also adds an emoji clustering dataset (~1 kB in size).