.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/scatter/scatter_size.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__gallery_scatter_scatter_size.py: Scatter Plot Size ================= Example showing point size change for scatter plot. .. GENERATED FROM PYTHON SOURCE LINES 7-47 .. image-sg:: /_gallery/scatter/images/sphx_glr_scatter_size_001.webp :alt: scatter size :srcset: /_gallery/scatter/images/sphx_glr_scatter_size_001.webp :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/fastplotlib/fastplotlib/fastplotlib/graphics/_features/_base.py:18: UserWarning: casting float64 array to float32 warn(f"casting {array.dtype} array to float32") | .. code-block:: Python # test_example = true import numpy as np import fastplotlib as fpl # figure with 2 rows and 3 columns shape = (2, 1) # you can give string names for each subplot within the gridplot names = [["scalar_size"], ["array_size"]] # Create the grid plot figure = fpl.Figure(shape=shape, names=names, size=(700, 560)) # get y_values using sin function angles = np.arange(0, 20 * np.pi + 0.001, np.pi / 20) y_values = 30 * np.sin(angles) # 1 thousand points x_values = np.array([x for x in range(len(y_values))], dtype=np.float32) data = np.column_stack([x_values, y_values]) figure["scalar_size"].add_scatter( data=data, sizes=5, colors="blue" ) # add a set of scalar sizes non_scalar_sizes = np.abs((y_values / np.pi)) # ensure minimum size of 5 figure["array_size"].add_scatter(data=data, sizes=non_scalar_sizes, colors="red") for graph in figure: graph.auto_scale(maintain_aspect=True) figure.show() # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter if __name__ == "__main__": print(__doc__) fpl.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.913 seconds) .. _sphx_glr_download__gallery_scatter_scatter_size.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: scatter_size.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: scatter_size.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: scatter_size.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_