-
-
Notifications
You must be signed in to change notification settings - Fork 403
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 scalebar support #6002
Add scalebar support #6002
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6002 +/- ##
==========================================
+ Coverage 88.48% 88.49% +0.01%
==========================================
Files 323 323
Lines 67640 67728 +88
==========================================
+ Hits 59848 59933 +85
- Misses 7792 7795 +3 ☔ View full report in Codecov by Sentry. |
holoviews/plotting/bokeh/element.py
Outdated
|
||
from bokeh.models import ScaleBar | ||
|
||
kdims = self.hmap.last.kdims |
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.
Maybe not the best way, but I couldn't figure out other ways to get the kdims.
I added a scalebar to the base Example of scalebar with import holoviews as hv
import numpy as np
hv.extension("bokeh")
c1 = hv.Curve(np.random.rand(1000), label='c1').opts(subcoordinate_y=True, scalebar=True, scalebar_location="bottom_left", scalebar_unit="cm")
c2 = hv.Curve(np.random.rand(1000), label='c2').opts(subcoordinate_y=True, scalebar=True, scalebar_location="top_left")
curves = hv.Overlay(c1 * c2)
curves.opts(width=800, height=800) simplescreenrecorder-2023-12-22_13.18.15.mp4I'm not sure where to put the documentation for this feature; honestly, I would rather wait with it until custom units are supported in Bokeh. |
Linking to the Bokeh PR for custom units |
What is left to do for this PR? |
Implement the custom unit introduced in bokeh/bokeh#13625 |
Just to connect this PR with the original use-case requirements spec: holoviz-topics/neuro#34 |
I have added a tool to hide scale bars. import holoviews as hv
import numpy as np
hv.extension("bokeh")
c1 = hv.Curve(np.random.rand(1000) + 2, label="c1").opts(
scalebar=True, scalebar_location="bottom_left", scalebar_unit="cm"
)
c2 = hv.Curve(np.random.rand(1000), label="c2").opts(scalebar=True, scalebar_location="top_left")
curves = hv.Overlay(c1 * c2)
curves.opts(width=800, height=800) screenrecord-2024-05-28_19.37.06.mp4 |
What's with the html? I see other reference notebooks just using markdown <div class="contentcontainer med left" style="margin-left: -50px;">
<dl class="dl-horizontal">
<dt>Title</dt> <dd> Scalebar</dd>
<dt>Dependencies</dt> <dd>Bokeh</dd>
<dt>Backends</dt>
<dd><a href='./Scalebar.ipynb'>Bokeh</a></dd>
</dl>
</div> |
Honest to god, I just clicked on a random reference guide, and that was how it was done in that 🤷♂️
You are right. That is the way to do it. Just if you are unaware, Maybe we should update the Example to show how to use |
I also don't yet see support for a |
Was an earlier name for |
scalebar = param.Boolean(default=False, doc=""" | ||
Whether to display a scalebar.""") | ||
|
||
scalebar_range =param.Selector(default="x", objects=["x", "y"], doc=""" |
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.
scalebar_range =param.Selector(default="x", objects=["x", "y"], doc=""" | |
scalebar_range = param.Selector(default="x", objects=["x", "y"], doc=""" |
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 okay with merging this but ideally we'd handle updates to the scalebar options.
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. |
Fixes #5948
I'm not entirely sure what plot classes need to have a scalebar option: all of them or a selective few. For now, I have added it to
RGB
to start with.Also, I am not sure how many of the
Scalebar
options we should have available.image_download