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

RFC: Subplot labeling. Fixes #998 #1331

Merged
merged 2 commits into from
Jan 15, 2018

Conversation

apalugniok
Copy link
Member

@apalugniok apalugniok commented Dec 19, 2017

#998
I opted for ann = (:top_left, :auto) instead of ann = :top as it makes the processing easier.

using Plots
plot(rand(10,8), ann = (:top_left, :auto), layout = grid(2,2))

autolabels

plot(rand(10,8), 
ann = [([:top_left, :top_right], ["test", "(b)"]) (:top_center, :auto) ([5, 9], 0.5, ["middle", "stuff"])],
layout = grid(2,2))

customlabels

Note:

  • Polar plot annotations don't behave well. The interpretation of annotation coordinates differs between backends.
  • 3D plots also don't work.

@apalugniok apalugniok force-pushed the subplot-labeling branch 2 times, most recently from 4b25d39 to 24ef12a Compare December 31, 2017 17:57
@apalugniok apalugniok changed the title WIP Subplot labeling. Fixes #998 RFC: Subplot labeling. Fixes #998 Jan 13, 2018
Copy link
Member

@daschw daschw left a comment

Choose a reason for hiding this comment

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

Really great work @apalugniok !

# Give each annotation coordinates based on specified position
function locate_annotation(sp::Subplot, pos::Symbol, lab::PlotText)
position_multiplier = Dict{Symbol, Tuple{Float64,Float64}}(
:top_left => (0.1, 0.9),
Copy link
Member

Choose a reason for hiding this comment

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

I'd use versions without underscores (:topleft, ...) here to be consistent with the position options for the legend attribute.
The Plots way would probably be to allow both versions, as well as :t, :tl, :tr, ... for annotations and legendpositions. This could be achieved by introducing a _positionAliases Dict and do some preprocessing in args.jl.

@apalugniok
Copy link
Member Author

apalugniok commented Jan 14, 2018

Forgot to mention Plotly cannot deal with annotations when multiple subplots are present.

plot(rand(10,8), ann = (:bottom_left, :auto), layout = grid(2,2))

brokenplotly

@daschw
Copy link
Member

daschw commented Jan 15, 2018

IMO we can merge this and open an issue for plotly.

@apalugniok apalugniok merged commit 0f9bb77 into JuliaPlots:master Jan 15, 2018
@abehersan
Copy link

Hi! I just realized this convenience feature existed from the discourse posts! Is it documented in the API guide at all and I just missed it entirely? I could not find anything...

@BeastyBlacksmith
Copy link
Member

I don't think it is documented

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.

4 participants