.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "11_demos\itom\plots\demoPickPointsAndMarkers.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_11_demos_itom_plots_demoPickPointsAndMarkers.py: Pick points and markers ========================== This demo shows how you can pick points and markers in the ``itom`` plot. .. GENERATED FROM PYTHON SOURCE LINES 5-10 .. code-block:: Python from itom import dataObject from itom import plot2 from itom import plotItem .. GENERATED FROM PYTHON SOURCE LINES 12-15 **Pick Points demo** Create a random 2 dimensional ``dataObject`` and plot it. .. GENERATED FROM PYTHON SOURCE LINES 15-20 .. code-block:: Python obj = dataObject.randN([1024, 1024], "int16") [nr, h] = plot2(obj) h["title"] = "Showcase: pick marker" .. GENERATED FROM PYTHON SOURCE LINES 21-23 .. image:: ../../_static/demoPickPointsAndMarkers_1.png :width: 100% .. GENERATED FROM PYTHON SOURCE LINES 25-26 This command let the user pick maximum 4 points (earlier break with space, esc aborts the selection). .. GENERATED FROM PYTHON SOURCE LINES 26-33 .. code-block:: Python pickedPoints = dataObject() h.pickPoints(pickedPoints, 4) print("coordinates of selected points: ") for numPoint in range(pickedPoints.shape[1]): print(f"x: {pickedPoints[0, numPoint]}, y: {pickedPoints[1, numPoint]}") .. GENERATED FROM PYTHON SOURCE LINES 34-46 Plot the ``dataObject`` again together with the previously selected points as ``marker``. The second argument of ``plotMarkers`` is a style-string (this may change) ``[color, symbol, size]``: +----------+------------------------------------------+ | color | \{b, g, r, c, m, y, k, w\} | +----------+------------------------------------------+ | symbol | \{., o, s, d, >, v, ^, <, x, `*`, +, h\} | +----------+------------------------------------------+ | size | any integer number | +----------+------------------------------------------+ .. GENERATED FROM PYTHON SOURCE LINES 46-53 .. code-block:: Python markers = dataObject([2, 3], "float32", data=[10.1, 20.2, 30.3, 7, 100, 500]) [nr, h] = plot2(obj) h["title"] = "Showcase: plot the currently selected points" h.call( "plotMarkers", pickedPoints, "b+10", "setName" ) # 'setName' is the name for this set of markers (optional) .. GENERATED FROM PYTHON SOURCE LINES 54-56 .. image:: ../../_static/demoPickPointsAndMarkers_2.png :width: 100% .. GENERATED FROM PYTHON SOURCE LINES 58-59 Delete marker set .. GENERATED FROM PYTHON SOURCE LINES 59-62 .. code-block:: Python h.call("deleteMarkers", "setName") # deletes given set h.call("deleteMarkers", "") # deletes all sets .. GENERATED FROM PYTHON SOURCE LINES 63-66 **Paint geometric shapes** Create a random 2 dimensional ``dataObject`` and plot it. .. GENERATED FROM PYTHON SOURCE LINES 66-70 .. code-block:: Python obj = dataObject.randN([1024, 1024], "int16") [nr, h] = plot2(obj) h["title"] = "Showcase: paint 4 ellipses" .. GENERATED FROM PYTHON SOURCE LINES 71-72 This command let the user pick maximum 4 points (earlier break with space, esc aborts the selection). .. GENERATED FROM PYTHON SOURCE LINES 72-78 .. code-block:: Python geometricShapes = h.drawAndPickElements(plotItem.PrimitiveEllipse, 4) print("selected shapes:") for shape in geometricShapes: print(shape) .. GENERATED FROM PYTHON SOURCE LINES 79-80 Plot the ``dataObject`` again together with the previously painted ellipses ``geometricShapes``. .. GENERATED FROM PYTHON SOURCE LINES 80-87 .. code-block:: Python [nr, hDrawInto] = plot2(obj) hDrawInto["title"] = "Showcase: plot painted ellipses" hDrawInto.call( "setGeometricShapes", geometricShapes ) # "b" and "setname" will be ignored anyway shapes = hDrawInto["geometricShapes"] .. GENERATED FROM PYTHON SOURCE LINES 88-90 .. image:: ../../_static/demoPickPointsAndMarkers_3.png :width: 100% .. _sphx_glr_download_11_demos_itom_plots_demoPickPointsAndMarkers.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demoPickPointsAndMarkers.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demoPickPointsAndMarkers.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: demoPickPointsAndMarkers.zip `