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

how to change HLine's axis range #3679

Closed
cocoaaa opened this issue Apr 30, 2019 · 7 comments
Closed

how to change HLine's axis range #3679

cocoaaa opened this issue Apr 30, 2019 · 7 comments

Comments

@cocoaaa
Copy link

cocoaaa commented Apr 30, 2019

Hi,
What is a recommended way to set the axis range of HLine objects?
The three methods recommended In #1717 doesn't work on HLine object. My guess is that this is because HLine and Curve are semantically different: HLine is considered a function defined on all real values whereas Curve is defined on the range specified in the user's input data. Please correct me if that's not the reasoning behind it. For HLine objects, then, how can I change the ylim range (eg. using the redim method)?

Here are my quick test cases. It seems to work with only matplotlib as the backend, not bokeh, which seems to be aligned with bokeh's API, but the option of ylim appears on the auto-tabcomplete of HoloViews.

image
image

Another strange behavior is that the backend keyword inside (object).opts doesn't override the option set by hv.extension method. I would expect this to override the backend option for the caller object. Could you clarify if this is an intended outcome?

Slightly different, but related question is, is it possible to set a default figure size (height and width) using %%opts or opts.defaults method without specifying the element type?

Thanks!

@jbednar
Copy link
Member

jbednar commented Apr 30, 2019

If you want the line to have a specific extent, usually you would use hv.Path(). hv.HLine is for annotating other plots, where it is not intended to modify the other plot's extents.

The backend keyword in .opts() declares which backend the options are to be applied to, for cases where the same object can be customized appropriately for multiple backends. But this is a declaration only; it does not actually force the object to be displayed with any particular backend when it is later shown. I wish we could make that behavior more obvious somehow, but I can't think how to make that clearer.

@cocoaaa
Copy link
Author

cocoaaa commented Apr 30, 2019

Thank you for your quick response.
I thought hv.HLine would be the right type to use if I wantto add a horizontal line to a figure of Curve. I noticed that the container object (eg. curve * hline)'s ylim can be modified via opts(ylim=(a,b)) and was expecting the same would work for hv.HLine element:

image

Just sharing what I was expecting as a user:)
I guess in most cases, though, people wouldn't really draw a single horizontal but would overlay it to another figure.

@jbednar
Copy link
Member

jbednar commented Apr 30, 2019

It was certainly the intention that an HLine would only be used as an overlay on other data, but it would still be nice if we could make it behave more intuitively when used on its own, so that people could go naturally between overlaid and non-overlaid contexts. Unfortunately, a lot of how it works is inherited from Bokeh and difficult for us to change, but other HoloViews developers may be able to suggest ways we can make it work in a less surprising way.

@cocoaaa
Copy link
Author

cocoaaa commented Apr 30, 2019

I see. Another good feature would be to have the axis ranges automatically reset so as to it shows all elements involved. In the first figure above, for example, the container's ylim doesn't consider HLine element's range. Is this already implemented in HoloViews?

@jbednar
Copy link
Member

jbednar commented May 1, 2019

Again, HLine's extents are deliberately not considered when setting ranges. E.g. one might put an annotation for "absolute upper limit", which should show if that value is ever reached, but isn't relevant otherwise. Annotations aren't meant to be used as data, but in principle we could add additional elements that look like the annotations but do behave like data, add an option to the annotation to make it act like data, or something of that sort...

@philippjfr
Copy link
Member

This can be controlled by setting .opts(apply_ranges=True).

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants