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

Add support for ScaleBar annotation #13319

Merged
merged 24 commits into from Sep 28, 2023
Merged

Conversation

mattpap
Copy link
Contributor

@mattpap mattpap commented Aug 9, 2023

TODO:

  • finish vertical orientation
  • two-dimensional scale bar
  • support geographical projections (maps)
  • finish the internal layout of the annotation
  • move computational logic to Dimensional models
  • make Dimensional models configurable
  • add more predefined units and bases
  • label/title alignment
  • allow bar length in pixels
  • allow bar decorations (e.g. tee head)
  • add support for an exact mode
  • add support math text (or at least unicode e.g. for um)
  • add more examples
  • add tests

Example:

scale_bar = ScaleBar(
    range=p.x_range,
    unit="mm",
    dimensional=MetricLength(), 
    orientation="horizontal",
    location="top_right",
    label_location="above",
    bar_length=0.2,
    bar_line_width=2,
    background_fill_alpha=0.8,
)

image

Note that displaying both a plain bar and an axis is just for the sake of the example and won't be the default.

This incorporates PR #13106.

fixes #11755

@mattpap mattpap added this to the 3.3 milestone Aug 9, 2023
@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #13319 (831ae5a) into branch-3.3 (0bdaa42) will increase coverage by 0.02%.
Report is 5 commits behind head on branch-3.3.
The diff coverage is 100.00%.

@@              Coverage Diff               @@
##           branch-3.3   #13319      +/-   ##
==============================================
+ Coverage       92.44%   92.47%   +0.02%     
==============================================
  Files             317      318       +1     
  Lines           20264    20339      +75     
==============================================
+ Hits            18734    18809      +75     
  Misses           1530     1530              

@droumis droumis mentioned this pull request Aug 11, 2023
16 tasks
@mattpap mattpap added the grant: CZI R5 Funded by CZI Round 5 grant label Aug 12, 2023
@mattpap mattpap force-pushed the mattpap/11755_scale_bar branch 3 times, most recently from a0e0ba9 to 555284c Compare September 19, 2023 15:29
@droumis
Copy link
Member

droumis commented Sep 20, 2023

@mattpap is this ready for review, given that geo projections and 2D will be in a different PR?

@mattpap
Copy link
Contributor Author

mattpap commented Sep 21, 2023

is this ready for review, given that geo projections and 2D will be in a different PR?

Tentatively yes, but I'm still working on multiple issues.

@mattpap mattpap force-pushed the mattpap/11755_scale_bar branch 2 times, most recently from f9988ff to 34cab71 Compare September 24, 2023 12:37
Copy link
Member

@ianthomas23 ianthomas23 left a comment

Choose a reason for hiding this comment

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

The appearance and zooming look really good.

There are rather a lot of properties of ScaleBar but I cannot see how to get rid of any of them, and I presume that default values will be fine for most use cases.

src/bokeh/models/annotations/legends.py Outdated Show resolved Hide resolved
src/bokeh/models/annotations/legends.py Outdated Show resolved Hide resolved
src/bokeh/models/annotations/legends.py Outdated Show resolved Hide resolved
src/bokeh/models/annotations/legends.py Show resolved Hide resolved
src/bokeh/models/annotations/legends.py Outdated Show resolved Hide resolved
bokehjs/src/lib/models/annotations/scale_bar.ts Outdated Show resolved Hide resolved
bokehjs/src/lib/models/annotations/scale_bar.ts Outdated Show resolved Hide resolved
bokehjs/src/lib/models/annotations/scale_bar.ts Outdated Show resolved Hide resolved
bokehjs/src/lib/models/annotations/scale_bar.ts Outdated Show resolved Hide resolved
src/bokeh/models/annotations/legends.py Outdated Show resolved Hide resolved
@mattpap
Copy link
Contributor Author

mattpap commented Sep 27, 2023

There are rather a lot of properties of ScaleBar but I cannot see how to get rid of any of them, and I presume that default values will be fine for most use cases.

Which ones specifically? Many of those properties were "inherited" from Legend and ColorBar, and use the same default values. I've been considering to have a "bare" scale bar configurable in some way, i.e. no border, padding and background color and minimal spacing between its individual components.

@ianthomas23
Copy link
Member

There are rather a lot of properties of ScaleBar ...

Which ones specifically? ...

None specifically, they all look useful and worth keeping. I was just commenting that there are lots of properties which might make use of ScaleBar intimidating to users. But no action is required on this.

@mattpap mattpap merged commit 96546ee into branch-3.3 Sep 28, 2023
27 checks passed
@mattpap mattpap deleted the mattpap/11755_scale_bar branch September 28, 2023 22:39
@gmerritt123
Copy link

Amazing thanks so much for implementing this feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
grant: CZI R5 Funded by CZI Round 5 grant status: accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Show scale in map
4 participants