Change x-axis (xlim) on holoviews histogram
In matplotlib, we can change the x-axis limits using the xlim () method. Is there an equivalent method in HoloViews?
I looked through the HV page but couldn't find anything that could do this.
I created the image below with the following code in a Jupyter notebook:
import numpy as np
import holoviews as hv
hv.notebook_extension('bokeh', width=90)
values = np.array([list of floats])
frequencies, edges = np.histogram(values, 10)
hv.Histogram(frequencies, edges)
How to change the x-axis limit to [0.002, 0.016].
Also, is it possible to get a graph to return its current x-axis limit?
+2
source to share
2 answers
HoloViews usually just use the data boundaries that you give them. So the easiest way to change the bounds of the histogram is to change it in the call to np.histogram itself:
frequencies, edges = np.histogram(values, 10, range=(0.002, 0.016))
hv.Histogram(frequencies, edges)
If you just want to change the viewing extents, you can also set them directly:
hv.Histogram(frequencies, edges, extents=(0.002, None, 0.016, None))
where extents are defined as (xmin, ymin, xmax, ymax)
.
+3
source to share