-
-
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
Proposed API for twin-axis support #5355
Comments
Allowing twin axes makes sense too for two elements that are not of the same type. E.g. in this example taken from Microsoft's site: https://support.microsoft.com/en-us/office/add-or-remove-a-secondary-axis-in-a-chart-in-excel-91da1e2f-5db1-41e9-8908-e1a2e14dd5a9#OfficeVersion=macOS |
I agree that they don't make much sense for Points and Paths, nor for dense rasters or geo maps, but I wouldn't disallow those if it takes extra work to do so. It's hard to anticipate all the ways someone might use this functionality, some of which are abuses but others might end up useful.
It's hard to see overlaying two bar charts as useful since bar charts themselves already support stacking or side by side bars, but again, maybe not worth the effort of figuring out which ones are truly useless, and which ones are just rarely useful. |
I should also note (as @philippjfr pointed out to me) that we've had discussion about potential API before (e.g. in the issues I referenced above). Here, I've described the API that currently makes sense to me but we should revisit those issues as I am open to other possible suggestions... |
Haven't put much thoughts in that but an alternative could be a 2nd overlay operator, e.g. the division (maybe it's already taken for something, haven't checked):
EDIT: fixed the code |
That would indeed be a possible approach but we are wary of adding new operators. In particular, we have discussed using |
It's maybe a terrible idea but it just struck me that we actually can have an unlimited supply of infix operators in Python if we are ready to make pylint scream about the missing whitespaces: class Meta(type):
def __rlshift__(self, left):
return self(left)
class Op(metaclass=Meta):
def __init__(self, left):
self.left = left
def __rshift__(self, right):
return self.op(self.left, right)
class Custom(Op):
@staticmethod
def op(left, right):
return left * right
# We just created a new operator "<<Custom>>"
print(3 <<Custom>> 2) |
Trying to plot double BoxWhiskers with double y axis for 'height' and 'weight' ... running into so much trouble
|
Unfortunately, HoloViews does not support twin axes well right now and any workarounds that might work aren't great. We do want to support it better in the future though! |
There is a user requesting it here https://discourse.holoviz.org/t/how-to-implement-secondary-y-axis/4317/2 I also need it for my use cases. |
This is an essential feature for holoviews in my opinion. I do need this feature in my workflow. |
It's a funded task on our list, so I hope we'll get to it soon, but we do have a bunch of priorities to juggle, so it's hard to promise anything! |
Hi, is there any development on this? In my line of work this is crucial, for example to plot Temperature in Primary y-axis (left) and Pressure in Secondary y-axis (right) with Time in the x-axis. This is not allowing me to use HvPlot unfortunately. Thanks! |
There is! Thank you for bumping this issue! Sorry, I should have referenced this issue in the PR that was merged (and now released): #5621 The API is to use Closing. |
Thanks, does it have direct application in HvPlot? |
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. |
Twin axes is an often requested feature (e.g. see #396, #1594, #3011) and HoloViews should support this type of plot without having to resort to ugly custom hooks.
In this issue I would like to propose an API for discussion. In particular, I think the most intuitive approach would be to support twin-axes by creating a simple overlay, where one of the components has
yaxis='twin'
specified as a plot option. Right now, the possible values foryaxis
(for bokeh) are['left', 'right', None, True, False]
which means'twin'
would be added to this list. For matplotlib, the options are['left', 'right', None]
(I don't see why true and False shouldn't also be supported here though!)As
'left'
and'right'
are already supported, using'twin'
would add axes on the opposite side for the component it is attached to. For instance:curve1 * curve2.opts(yaxis='twin')
: curve1 has its yaxis on the left (default) and curve2 has its yaxis on the rightcurve1.opts(yaxis='right') * curve2.opts(yaxis='twin')
: curve1 has its yaxis on the right and curve2 has its yaxis on the leftI think this would be intuitive enough given how everything currently works. In principle, this should support overlaying two
NdOverlays
so that you have two legends, one for each side.Suggested rules:
Points
andPaths
which exist in a homogenous 2D space (where you can sensibly imagine rotations). I don't think this option will make sense for all element types (e.g. can this really be sensible for bar charts?)The text was updated successfully, but these errors were encountered: