diff --git a/doc/Homepage.ipynb b/doc/Homepage.ipynb deleted file mode 100644 index 00a6e55ddb..0000000000 --- a/doc/Homepage.ipynb +++ /dev/null @@ -1,83 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "HoloViews is a [Python](http://python.org) library that makes analyzing and visualizing scientific or engineering data much simpler, more intuitive, and more easily reproducible. Instead of specifying every step for each plot, HoloViews lets you store your data in an annotated format that is instantly visualizable, with immediate access to both the numeric data *and* its visualization. Examples of how HoloViews is used in Python scripts as well as in live [Jupyter Notebooks](http://jupyter.org) may be accessed directly from the [holoviews gallery](http://holoviews.org/gallery/index.html) webpage. Here is a quick example of HoloViews in action:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "import holoviews as hv\n", - "hv.notebook_extension('matplotlib')\n", - "fractal = hv.Image(np.load('mandelbrot.npy'))\n", - "\n", - "((fractal * hv.HLine(y=0)).hist() + fractal.sample(y=0))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Fundamentally, a HoloViews object is just a thin wrapper around your data, with the data always being accessible in its native numerical format, but with the data displaying itself automatically whether alone or alongside or overlaid with other HoloViews objects as shown above. The actual rendering is done using a separate library like [matplotlib](http://matplotlib.org) or [bokeh](http://bokeh.pydata.org), but all of the HoloViews objects can be used without any plotting library available, so that you can easily create, save, load, and manipulate HoloViews objects from within your own programs for later analysis. HoloViews objects support arbitrarily high dimensions, using continuous, discrete, or categorical indexes and values, with flat or hierarchical organizations, and sparse or dense data formats. The objects can then be flexibly combined, selected, sliced, sorted, sampled, or animated, all by specifying what data you want to see rather than by writing plotting code. The goal is to put the plotting code into the background, as an implementation detail to be written once and reused often, letting you focus clearly on your data itself in daily work." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## More detailed example" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Even extremely complex relationships between data elements can be expressed succinctly in HoloViews, allowing you to explore them with ease:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "%%opts Points [scaling_factor=50] Contours (color='w')\n", - "dots = np.linspace(-0.45, 0.45, 19)\n", - "\n", - "layouts = {y: (fractal * hv.Points(fractal.sample([(i,y) for i in dots])) +\n", - " fractal.sample(y=y) +\n", - " hv.operation.threshold(fractal, level=np.percentile(fractal.sample(y=y)['z'], 90)) +\n", - " hv.operation.contours(fractal, levels=[np.percentile(fractal.sample(y=y)['z'], 60)]))\n", - " for y in np.linspace(-0.3, 0.3, 21)}\n", - "\n", - "hv.HoloMap(layouts, kdims=['Y']).collate().cols(2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here we have built a dictionary indexed by a numerical value `y`, containing a set of ``Layout`` objects that are each composed of four HoloViews objects. We then collated the ``Layout`` objects into a HoloViews data structure that can display arbitrarily high dimensional data. The result is that in **A** we can see the same fractal data as above, but with a horizontal cross section indicated using a set of dots with sizes proportional to the underlying data values, illustrating how even a simple annotation can be used to reflect other data of interest. **B** shows a cross-section of the fractal, **C** shows a thresholded version of it, and **D** shows the same data with a contour outline overlaid. The threshold and contour levels used are not fixed, but are calculated as the 90th or 60th percentile of the data values along the selected cross section, using standard Python/NumPy functions. All of this data is packaged into a single HoloViews data structure for a range of cross sections, allowing the data for a particular cross section to be revealed by moving the Y-value slider at right. Even with these complicated interrelationships between data elements, the code still only needs to focus on the data that you want to see, not on the details of the plotting or interactive controls, which are handled by HoloViews and the underlying plotting libraries.\n", - "\n", - "Note that just as the 2D array became a 1D curve automatically by sampling to get the cross section, this entire figure would become a single static frame with no slider bar if you chose a specific ``Y`` value by re-running with ``.select(Y=0.3)`` before ``.cols(2)``. There is nothing in the code above that adds the slider bar explicitly -- it appears automatically, just because there is an additional dimension of data that has not been laid out spatially. Additional sliders would appear if there were other dimensions being varied as well, e.g. for parameter-space explorations.\n", - "\n", - "This functionality is designed to complement the [IPython/Jupyter Notebook](http://jupyter.org) interface, though it can be used just as well separately. This web page and all the [HoloViews Tutorials](Tutorials/) are runnable notebooks, which allow you to interleave text, Python code, and graphical results easily. With HoloViews, you can put a minimum of code in the notebook (typically one or two lines per subfigure), specifying what you would like to see rather than the details of how it should be plotted. HoloViews makes the IPython Notebook a practical solution for both exploratory research (since viewing nearly any chunk of data just takes a line or two of code) and for long-term [reproducibility](Tutorials/Exporting.html) of the work (because both the code and the visualizations are preserved in the notebook file forever, and the data and publishable figures can both easily be exported to an archive on disk). See the [Tutorials](Tutorials/) for detailed examples, and then start enjoying working with your data!" - ] - } - ], - "metadata": { - "language_info": { - "name": "python", - "pygments_lexer": "ipython3" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/holoviews/operation/element.py b/holoviews/operation/element.py index 2bb914b55d..0d8bc13246 100644 --- a/holoviews/operation/element.py +++ b/holoviews/operation/element.py @@ -908,7 +908,7 @@ def _process(self, element, key=None): if normed == 'height': hist /= hist.max() else: - hist, edges = np.histogram(data, normed=normed, weights=weights, bins=edges) + hist, edges = np.histogram(data, density=normed, weights=weights, bins=edges) if self.p.weight_dimension and self.p.mean_weighted: hist_mean, _ = np.histogram(data, density=False, bins=self.p.num_bins) hist /= hist_mean diff --git a/holoviews/tests/core/test_layouts.py b/holoviews/tests/core/test_layouts.py index 8c53eb5ce8..83d8f47ff1 100644 --- a/holoviews/tests/core/test_layouts.py +++ b/holoviews/tests/core/test_layouts.py @@ -1,6 +1,9 @@ """ Tests of Layout and related classes """ +import numpy as np +import pytest + from holoviews import ( AdjointLayout, Element, @@ -10,7 +13,7 @@ NdLayout, Overlay, ) -from holoviews.element import Curve, HLine +from holoviews.element import Curve, HLine, Image from holoviews.element.comparison import ComparisonTestCase @@ -129,7 +132,14 @@ def test_adjointlayout_overlay_adjoined_holomap_nomatch_too_many(self): with self.assertRaises(ValueError): (self.view1 << self.view2 << self.view3) * (self.hmap << dim_view) + @pytest.mark.usefixtures("mpl_backend") + def test_histogram_image_hline_overlay(self): + image = Image(np.arange(100).reshape(10, 10)) + overlay = image * HLine(y=0) + element = overlay.hist() + assert isinstance(element, AdjointLayout) + assert element.main == overlay class NdLayoutTest(CompositeTest):