.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` to download the full example code
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_auto_examples_plot_optimizedalpha.py:
Optimized Alpha Example
=======================
Using the optimized alpha function for obtaining the alpha parameter.
.. image:: /auto_examples/images/sphx_glr_plot_optimizedalpha_001.png
:alt: plot optimizedalpha
:class: sphx-glr-single-img
.. code-block:: default
:lineno-start: 8
import alphashape
import matplotlib.pyplot as plt
from descartes import PolygonPatch
# Define input points
points = [(0., 0.), (0., 1.), (1., 1.), (1., 0.),
(0.5, 0.25), (0.5, 0.75), (0.25, 0.5), (0.75, 0.5)]
# Determine the optimized alpha parameter
alpha = alphashape.optimizealpha(points)
# Generate the alpha shape
alpha_shape = alphashape.alphashape(points, alpha)
# Initialize plot
fig, ax = plt.subplots()
# Plot input points
ax.scatter(*zip(*points))
# Plot alpha shape
ax.add_patch(PolygonPatch(alpha_shape, alpha=.2))
plt.show()
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 1.349 seconds)
.. _sphx_glr_download_auto_examples_plot_optimizedalpha.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: plot_optimizedalpha.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_optimizedalpha.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_