HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/holoviews/examples/reference/elements/bokeh/Ellipse.ipynb
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### **Title**: Ellipse Element\n",
    "\n",
    "**Dependencies**: Bokeh\n",
    "\n",
    "**Backends**: [Bokeh](./Ellipse.ipynb), [Matplotlib](../matplotlib/Ellipse.ipynb), [Plotly](../plotly/Ellipse.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import holoviews as hv\n",
    "from holoviews import opts\n",
    "hv.extension('bokeh')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "opts.defaults(opts.Ellipse(line_width=6))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "An ``Ellipse`` is an annotation that takes a center x-position, a center y-position, a size:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Generate some data\n",
    "c1 = np.random.normal(loc=2, scale=0.2, size=(200,200))\n",
    "c2x = np.random.normal(loc=-2, scale=0.6, size=200)\n",
    "c2y = np.random.normal(loc=-2, scale=0.1, size=200)\n",
    "c3 = np.random.normal(loc=0, scale=1.5, size=(400,400))\n",
    "# Create an overlay of points and ellipses\n",
    "clusters = hv.Points(c1) * hv.Points((c2x, c2y)) * hv.Points(c3)\n",
    "clusters * hv.Ellipse(2,2, 2) * hv.Ellipse(-2,-2, (4,2)) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "By default, the size is just a diameter, resulting in a circle such as the blue circle above. Alternatively, the size can be given as the tuple ``(width, height)`` as shown for the red ellipse above. If you only supply a diameter, you can still specify an ellipse by specifying an optional aspect value. In addition, you can also set the orientation (in radians, rotating anticlockwise):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "clusters = hv.Points(c1) * hv.Points((c2x, c2y)) * hv.Points(c3)\n",
    "clusters *  hv.Ellipse(0,0, 4, orientation=np.pi/5, aspect=2) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For full documentation and the available style and plot options, use ``hv.help(hv.Ellipse).``"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}