MattCowgill / ggannotate

Interactively annotate ggplots
Other
309 stars 20 forks source link

Refinements to multiple annotations #11

Open MattCowgill opened 4 years ago

MattCowgill commented 4 years ago

At the moment the Shiny gadget can only add one annotation at a time. The user can copy their code out and then repeat the process to do multiple annotations. They should be able to do multiple within the one Shiny window. This will require properly modularising the Shiny app.

jhelvy commented 3 years ago

I just started working on a similar app before discovering yours. I found a way to include multiple annotations on the same plot: https://github.com/jhelvy/gglabelr

I think this is a pretty useful feature as you'll often want to add a label + curve / line / box, and it's hard to get those aligned right without seeing them both at the same time.

Since your UI has already incorporated so many of the features that I wanted to add to mine, I'm happy to abandon mine and contribute to yours.

MattCowgill commented 3 years ago

Hi @jhelvy -- your package is cool! I agree that multiple annotations is an important feature. The way I'd been thinking of doing it is a little different though -- I want users to be able to have multiple annotations of the same type (eg. multiple text labels). They'd select "annotation 1" or "annotation 2" etc. from a drop down box, then add the annotation.

Let me think about this, if that's OK. Thanks

jhelvy commented 3 years ago

I think this solution by @daattali on how to display multiple click points on a plot might be a good starting point. I was just starting to look into this myself when I found your app. I agree that it would best for the user to be able to add as many annotations as they want. In that case, it would also be nice to add buttons that allow the user to also remove each individual annotate as well in case they mess up or want to adjust it without having to redo all the other annotations, but that shouldn't be too hard to add once you've got the multi-annotation part solved.

jhelvy commented 3 years ago

This is looking really nice! It already achieves the functional goal, but yes there are some glitches. After playing around with it, here are some notes:

  1. The biggest glitch I see is that when I'm working on another layer (e.g. 2) and swap back to a previous layer (e.g. 1), that layer's annotation disappears. It should remain there and only change if I modify it.
  2. Maybe add a "delete / remove layer" button (which could potentially fix issue 1). That way the annotation will always remain unless the user specifically chooses to remove it.
  3. Similarly, maybe add an "add layer" button. You could still use the dropdown widget to select between layers (which I think works well from a UI perspective), but it could be dynamically populated based on the user creating new layers.
  4. Inside the layer dropdown, it would be nice to see the annotation type next to the number (e.g. 1 <rect>, 2 <label>). Something like this would help in distinguishing the annotation layers when you've got several and can't remember which was which.
  5. Maybe even give the option to add a layer id / name (though the user may confuse this with the actual label text)

With the above suggestions, here's what I'm envisioning in terms of the UI for the left sidebar:

"Select annotation layer"

[layer dropdown menu]

--------------------------------------------------------

"Create / modify annotation layer"

[Add layer button] [Delete layer button] [Geom dropdown menu]

--------------------------------------------------------

"Annotation parameters"

[all geom-specific widgets]
MattCowgill commented 3 years ago

Thanks John. Good suggestions. I'll address points 1 & 2 in the next update.

I'm unclear what option 3 would add, but am open to it. What's your thinking there?

Option 4 is a good idea, I'll think through how difficult it would be to implement.

I don't think I'll do option 5.

Cheers

jhelvy commented 3 years ago

I think option 3 would make it slightly more intuitive to understand how the tool works. My thought was the first layer would already be available on first launch, and the drop down menu would only have one annotation listed (the current one). Then the user would have to click on the "add layer" or "add annotation" button to create a second layer, which would then become the active layer and also show up in the drop down menu. It would be symmetric with the "delete layer" button (I think it might feel strange to have a delete button without an add button). Plus the user would know exactly how many annotations are present because the drop menu would only contain active annotations. Right now, there are 10 listed by default, but it's not clear whether any are active or not. Finally, I don't think this adds any extra effort on the part of the user - if they would have to click on the drop menu to swap to a new layer anyway, that's no extra effort than clicking an "add" button to swap to a new layer.

In terms of how all this should be laid out, I think there should be some sort of separation between 1) adding / deleting / swapping between layers and 2) the options for the "active" layer (which is how you already have the sidebar set up).