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 Curves axis ranges? #1717

Closed
nikhilxb opened this issue Jul 13, 2017 · 15 comments
Closed

How to change Curves axis ranges? #1717

nikhilxb opened this issue Jul 13, 2017 · 15 comments
Assignees
Labels
tag: API type: docs Related to the documentation and examples
Milestone

Comments

@nikhilxb
Copy link

I've been trying for hours to figure out how to change the x-axis range dynamically (with a DynamicMap). But nowhere on the user guide can I find examples of how to do this! It seems like it should be the easiest thing.

@philippjfr
Copy link
Member

philippjfr commented Jul 13, 2017

Agreed, this deserves more discussion and at minimum a major section in the documentation. I think what you are looking for is the {+framewise} normalization option, e.g.:

%%opts Curve {+framewise}
hv.DynamicMap(lambda i: hv.Curve(np.arange(i)), kdims=['i']).redim.range(i=((10, 20)))

Using the .opts method you can do it like this:

hv.DynamicMap(lambda i: hv.Curve(np.arange(i)), kdims=['i']).redim.range(i=((10, 20))).opts(norm=dict(framewise=True))

@philippjfr philippjfr added tag: API type: docs Related to the documentation and examples labels Jul 13, 2017
@philippjfr philippjfr added this to the 1.8.2 milestone Jul 13, 2017
@nikhilxb
Copy link
Author

Thank you, didn't know that existed, but it worked for me! I'm new to HoloViews, and actually the live plotting is what drove me to Bokeh, which led to HoloViews. The streaming functionality is a big pro, especially because it seems that Matplotlib doesn't have very good options and Plotly is either non-offline or paid.

@philippjfr
Copy link
Member

Thank you, didn't know that existed

That's our fault and we'll have to make this more obvious or find a more obvious way to control this. Great to hear HoloViews is addressing your problems. If you run into more issues please don't hesitate to file issues or ask us a question on Gitter.

@maegul
Copy link

maegul commented Aug 17, 2017

@philippjfr So is this not something that can be passed directly into a function or into an %%opts magic? If I read @nikhilxb 's question correctly, this seems to be intuitive disconnect, that something like axis ranges are not a customisation option I can access directly as I can line_color, width, etc.

I would never have thought of looking into .redim.range() ...
Is there a design choice behind this or are we missing something?

... also ... recently started using HoloViews, and I think your work and ideas on this are great.

@philippjfr philippjfr modified the milestones: 1.8.4, v1.9 Sep 20, 2017
@philippjfr philippjfr self-assigned this Oct 7, 2017
@jlstevens jlstevens modified the milestones: v1.9, v1.10 Nov 3, 2017
@philippjfr
Copy link
Member

@maegul Sorry for the delay on my reply, that is a sensible point and I would not actually object to adding explicit range plot options, particularly once we have completely deprecated the extents parameter on elements (I don't want three different ways to set the axis ranges). That said the range and soft_range are often things that are associated directly with a dimension and that you want to control at that level so I still think they are appropriate there.

@johnzzzz
Copy link

johnzzzz commented Jan 4, 2018

I think Charts need a first class way to set their Axes ranges. A Chart is a "view" on some dimensions/metrics that are part of a data "model". range and soft_range are attributes of a dimension, which is an aspect of the data model. A Chart can Inhert/Infer its default axis range from the data dimension range. But the Chart axis range belongs to the view and needs to be explicitly set. Think of two charts/views linked to the same data dimension/model. One chart/view could be set to zoom in on one range of data, while the other could be set to zoom out.

To make the idea of Inherit/Infer more general, think of the this transformation from model to view as something an advanced user needs to have control, i.e. a user defined function. For example, the Y-axis range should "go from 0 to the 95%-tile of the data values". The default behavior is for the Chart to inherit the axis range from the dimension, but the advance user should be able to override this behavior. Maybe the generic transformation between model and view attributes could be handled by the proposed "op" functions #2152

@neighthan
Copy link

I'd also be glad to be able to explicitly set the limits on the axes; I was surprised I couldn't find a way to do that with %%opts somehow. I have a Scatter chart that's cutting off the edges of my data, and zooming out a little each time I plot isn't nearly as nice as being able to adjust the limits (especially if I could do this by percentiles instead of having to calculate the min and max value for each axis to put this in %%opts).

@philippjfr
Copy link
Member

(especially if I could do this by percentiles instead of having to calculate the min and max value for each axis to put this in %%opts).

The next release will have an option for dimension range padding: #2293

@philippjfr philippjfr modified the milestones: v1.10, v1.11 Mar 19, 2018
@Gordon90s
Copy link

Gordon90s commented Jul 4, 2018

I've still not been able to find out how to set limits for the default plotting ranges - I don't understand how this "framework" method is supposed to work? Maybe this could be something that you could also address in "Customizing Plots" where no explicit example is given?

Say for the example:

import numpy as np
import holoviews as hv
hv.extension('bokeh')
xs = np.linspace(-np.pi,np.pi,100)
curve = hv.Curve((xs, xs/3))
curve

ranges for x: (-4,4), ranges for y: (-1.5,1.5).

@Gordon90s
Copy link

Ok, finally figured it out.

xs = np.linspace(-np.pi,np.pi,100)
curve = hv.Curve((xs, xs/3), extents = (-4,-1.5,4,1.5))
curve

I still think an explicit example should be given in "Customizing Plots"!

@philippjfr
Copy link
Member

Totally agree with you on Customizing plots having a section on this. Also note that extents is now by far the least preferred way of setting plot limits. The preferred approaches are:

  1. Setting the dimension ranges explicitly:
xdim = hv.Dimension('x_dim', range=(-4, 4))
ydim = hv.Dimension('y_dim', range=(-1.5, 1.5))
hv.Curve((xs, xs/3), xdim, ydim)
  1. Using redim.range:
hv.Curve((xs, xs/3), 'xdim', 'ydim').redim.range(xdim=(-4, 4), ydim=(-1.5, 1.5))
  1. On master there are now xlim and ylim plot options, which will be supported once 1.11 is released:
hv.Curve((xs, xs/3), 'xdim', 'ydim').options(xlim=(-4, 4), ylim=(-1.5, 1.5))

@darynwhite
Copy link
Contributor

Any chance the xlim and ylim options will be available on the Overlay object with 1.11?

@philippjfr
Copy link
Member

Any chance the xlim and ylim options will be available on the Overlay object with 1.11?

They will be yes. The semantics of xlim/ylim are such that setting it on any Element in an Overlay will override the ranges on any other Element in that Overlay, and setting it on the Overlay itself overrides everything.

@philippjfr philippjfr modified the milestones: v1.11.0, v1.11.x Nov 5, 2018
@philippjfr philippjfr modified the milestones: v1.11.x, v1.11.0 Nov 27, 2018
@philippjfr
Copy link
Member

This has been documented in FAQ items and in the docs now.

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
tag: API type: docs Related to the documentation and examples
Projects
None yet
Development

No branches or pull requests

8 participants