{ "info": { "author": "Thomas Robitaille", "author_email": "thomas.robitaille@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "|Travis Status| |AppVeyor Status| |Coverage Status|\n\nAbout\n-----\n\nPlotting millions of points can be slow. Real slow... :sleeping:\n\nSo why not use density maps? :zap:\n\nThe **mpl-scatter-density** mini-package provides functionality to make it easy\nto make your own scatter density maps, both for interactive and non-interactive\nuse. Fast. The following animation shows real-time interactive use with 10\nmillion points, but interactive performance is still good even with 100 million\npoints (and more if you have enough RAM).\n\n.. image:: https://github.com/astrofrog/mpl-scatter-density/raw/master/images/demo_taxi.gif\n :alt: Demo of mpl-scatter-density with NY taxi data\n :align: center\n\nWhen panning, the density map is shown at a lower resolution to keep things\nresponsive (though this is customizable).\n\nTo install, simply do::\n\n pip install mpl-scatter-density\n\nThis package requires `Numpy `_, `Matplotlib\n`_, and `fast-histogram\n`_ - these will be installed\nby pip if they are missing. Both Python 2.7 and Python 3.x are supported,\nand the package should work correctly on Linux, MacOS X, and Windows.\n\nUsage\n-----\n\nThere are two main ways to use **mpl-scatter-density**, both of which are\nexplained below.\n\nscatter_density method\n~~~~~~~~~~~~~~~~~~~~~~\n\nThe easiest way to use this package is to simply import ``mpl_scatter_density``,\nthen create Matplotlib axes as usual but adding a\n``projection='scatter_density'`` option (if your reaction is 'wait, what?', see\n`here `_).\nThis will return a ``ScatterDensityAxes`` instance that has a\n``scatter_density`` method in addition to all the usual methods (``scatter``,\n``plot``, etc.).\n\n.. code:: python\n\n import numpy as np\n import mpl_scatter_density\n import matplotlib.pyplot as plt\n\n # Generate fake data\n\n N = 10000000\n x = np.random.normal(4, 2, N)\n y = np.random.normal(3, 1, N)\n\n # Make the plot - note that for the projection option to work, the\n # mpl_scatter_density module has to be imported above.\n\n fig = plt.figure()\n ax = fig.add_subplot(1, 1, 1, projection='scatter_density')\n ax.scatter_density(x, y)\n ax.set_xlim(-5, 10)\n ax.set_ylim(-5, 10)\n fig.savefig('gaussian.png')\n\nWhich gives:\n\n.. image:: https://github.com/astrofrog/mpl-scatter-density/raw/master/images/gaussian.png\n :alt: Result from the example script\n :align: center\n\nThe ``scatter_density`` method takes the same options as ``imshow`` (for example\n``cmap``, ``alpha``, ``norm``, etc.), but also takes the following optional\narguments:\n\n* ``dpi``: this is an integer that is used to determine the resolution of the\n density map. By default, this is 72, but you can change it as needed, or set\n it to ``None`` to use the default for the Matplotlib backend you are using.\n\n* ``downres_factor``: this is an integer that is used to determine how much to\n downsample the density map when panning in interactive mode. Set this to 1\n if you don't want any downsampling.\n\n* ``color``: this can be set to any valid matplotlib color, and will be used\n to automatically make a monochromatic colormap based on this color. The\n colormap will fade to transparent, which means that this mode is ideal when\n showing multiple density maps together.\n\nHere is an example of using the ``color`` option:\n\n.. code:: python\n\n import numpy as np\n import matplotlib.pyplot as plt\n import mpl_scatter_density # noqa\n\n fig = plt.figure()\n ax = fig.add_subplot(1, 1, 1, projection='scatter_density')\n\n n = 10000000\n\n x = np.random.normal(0.5, 0.3, n)\n y = np.random.normal(0.5, 0.3, n)\n\n ax.scatter_density(x, y, color='red')\n\n x = np.random.normal(1.0, 0.2, n)\n y = np.random.normal(0.6, 0.2, n)\n\n ax.scatter_density(x, y, color='blue')\n\n ax.set_xlim(-0.5, 1.5)\n ax.set_ylim(-0.5, 1.5)\n\n fig.savefig('double.png')\n\nWhich produces the following output:\n\n.. image:: https://github.com/astrofrog/mpl-scatter-density/raw/master/images/double.png\n :alt: Result from the example script\n :align: center\n\nScatterDensityArtist\n~~~~~~~~~~~~~~~~~~~~\n\nIf you are a more experienced Matplotlib user, you might want to use the\n``ScatterDensityArtist`` directly (this is used behind the scenes in the\nabove example). To use this, initialize the ``ScatterDensityArtist`` with\nthe axes as first argument, followed by any arguments you would have passed\nto ``scatter_density`` above (you can also take a look at the docstring for\n``ScatterDensityArtist``). You should then add the artist to the axes:\n\n.. code:: python\n\n from mpl_scatter_density import ScatterDensityArtist\n a = ScatterDensityArtist(ax, x, y)\n ax.add_artist(a)\n\nAdvanced\n--------\n\nNon-linear stretches for high dynamic range plots\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIn some cases, your density map might have a high dynamic range, and you might\ntherefore want to show the log of the counts rather than the counts. You can do\nthis by passing a ``matplotlib.colors.Normalize`` object to the ``norm`` argument\nin the same wasy as for ``imshow``. For example, the `astropy\n`_ package includes a `nice framework\n`_\nfor making such a ``Normalize`` object for different functions. The following\nexample shows how to show the density map on a log scale:\n\n.. code:: python\n\n import numpy as np\n import mpl_scatter_density\n import matplotlib.pyplot as plt\n\n # Make the norm object to define the image stretch\n from astropy.visualization import LogStretch\n from astropy.visualization.mpl_normalize import ImageNormalize\n norm = ImageNormalize(vmin=0., vmax=1000, stretch=LogStretch())\n\n N = 10000000\n x = np.random.normal(4, 2, N)\n y = np.random.normal(3, 1, N)\n\n fig = plt.figure()\n ax = fig.add_subplot(1, 1, 1, projection='scatter_density')\n ax.scatter_density(x, y, norm=norm)\n ax.set_xlim(-5, 10)\n ax.set_ylim(-5, 10)\n fig.savefig('gaussian_log.png')\n\nWhich produces the following output:\n\n.. image:: https://github.com/astrofrog/mpl-scatter-density/raw/master/images/gaussian_log.png\n :alt: Result from the example script\n :align: center\n\nAdding a colorbar\n~~~~~~~~~~~~~~~~~\n\nYou can show a colorbar in the same way as you would for an image - the\nfollowing example shows how to do it:\n\n.. code:: python\n\n import numpy as np\n import mpl_scatter_density\n import matplotlib.pyplot as plt\n\n N = 10000000\n x = np.random.normal(4, 2, N)\n y = np.random.normal(3, 1, N)\n\n fig = plt.figure()\n ax = fig.add_subplot(1, 1, 1, projection='scatter_density')\n density = ax.scatter_density(x, y)\n ax.set_xlim(-5, 10)\n ax.set_ylim(-5, 10)\n fig.colorbar(density, label='Number of points per pixel')\n fig.savefig('gaussian_colorbar.png')\n\nWhich produces the following output:\n\n.. image:: https://github.com/astrofrog/mpl-scatter-density/raw/master/images/gaussian_colorbar.png\n :alt: Result from the example script\n :align: center\n\nColor-coding 'markers' with individual values\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIn the same way that a 1-D array of values can be passed to Matplotlib's\n``scatter`` function/method, a 1-D array of values can be passed to\n``scatter_density`` using the ``c=`` argument:\n\n.. code:: python\n\n import numpy as np\n import mpl_scatter_density\n import matplotlib.pyplot as plt\n\n N = 10000000\n x = np.random.normal(4, 2, N)\n y = np.random.normal(3, 1, N)\n c = x - y + np.random.normal(0, 5, N)\n\n fig = plt.figure()\n ax = fig.add_subplot(1, 1, 1, projection='scatter_density')\n ax.scatter_density(x, y, c=c, vmin=-10, vmax=+10, cmap=plt.cm.RdYlBu)\n ax.set_xlim(-5, 13)\n ax.set_ylim(-5, 11)\n fig.savefig('gaussian_color_coded.png')\n\nWhich produces the following output:\n\n.. image:: https://github.com/astrofrog/mpl-scatter-density/raw/master/images/gaussian_color_coded.png\n :alt: Result from the example script\n :align: center\n\nNote that to keep performance as good as possible, the values from the ``c``\nattribute are averaged inside each pixel of the density map, then the colormap\nis applied. This is a little different to what ``scatter`` would converge to in\nthe limit of many points (since in that case it would apply the color to all the\nmarkers than average the colors).\n\nQ&A\n---\n\nIsn't this basically the same as datashader?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThis follows the same ideas as\n`datashader `_, but the aim of\nmpl-scatter-density is specifically to bring datashader-like functionality to\nMatplotlib users. Furthermore, mpl-scatter-density is intended to be very easy\nto install - for example it can be installed with pip. But if you have\ndatashader installed and regularly use bokeh, mpl-scatter-density won't do much\nfor you. Note that if you are interested in datashader and Matplotlib together,\nthere is a work in progress (`pull request\n`_) by **@tacaswell** to create a\nMatplotlib artist similar to that in this package but powered by datashader.\n\nWhat about vaex?\n~~~~~~~~~~~~~~~~\n\n`Vaex `_ is a powerful package to\nvisualize large datasets on N-dimensional grids, and therefore has some\nfunctionality that overlaps with what is here. However, the aim of\nmpl-scatter-density is just to provide a lightweight solution to make\nit easy for users already using Matplotlib\nto add scatter density maps to their plots rather than provide a complete\nenvironment for data visualization. I highly recommend that you take a look\nat Vaex and determine which approach is right for you!\n\nWhy on earth have you defined scatter_density as a projection?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf you are a Matplotlib developer: I truly am sorry for distorting the intended\npurpose of ``projection`` :blush:. But you have to admit that it's a pretty\nconvenient way to have users get a custom Axes sub-class even if it has nothing\nto do with actual projection!\n\nWhere do you see this going?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThere are a number of things we could add to this package, for example a way to\nplot density maps as contours, or a way to color code each point by a third\nquantity and have that reflected in the density map. If you have ideas, please\nopen issues, and even better contribute a pull request! :smile:\n\nCan I contribute?\n~~~~~~~~~~~~~~~~~\n\nI'm glad you asked - of course you are very welcome to contribute! If you have\nsome ideas, you can open issues or create a pull request directly. Even if you\ndon't have time to contribute actual code changes, I would love to hear from you\nif you are having issues using this package.\n\n.. |Travis Status| image:: https://travis-ci.org/astrofrog/mpl-scatter-density.svg?branch=master\n :target: https://travis-ci.org/astrofrog/fast-histogram\n\n.. |AppVeyor Status| image:: https://ci.appveyor.com/api/projects/status/9a75dpq2489y9fig/branch/master?svg=true\n :target: https://ci.appveyor.com/project/astrofrog/mpl-scatter-density\n\n.. |Coverage Status| image:: https://codecov.io/gh/astrofrog/mpl-scatter-density/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/astrofrog/mpl-scatter-density\n\nRunning tests\n-------------\n\nTo run the tests, you will need `pytest `_\nand the `pytest-mpl `_ plugin. You can\nthen run the tests with::\n\n pytest mpl_scatter_density --mpl\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/astrofrog/mpl-scatter-density", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "mpl-scatter-density", "package_url": "https://pypi.org/project/mpl-scatter-density/", "platform": "", "project_url": "https://pypi.org/project/mpl-scatter-density/", "project_urls": { "Homepage": "https://github.com/astrofrog/mpl-scatter-density" }, "release_url": "https://pypi.org/project/mpl-scatter-density/0.6/", "requires_dist": [ "numpy", "matplotlib (>=2.0)", "fast-histogram (>=0.3)" ], "requires_python": "", "summary": "Matplotlib helpers to make density scatter plots", "version": "0.6" }, "last_serial": 5327851, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d235d9ceb924869d82b8e81c6f8b56d8", "sha256": "25f1e012afe504ca1b451b166bdbde5e966c4fd7447c4c68a062ad2107a82fa9" }, "downloads": -1, "filename": "mpl_scatter_density-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d235d9ceb924869d82b8e81c6f8b56d8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 1014777, "upload_time": "2017-07-19T17:04:42", "url": "https://files.pythonhosted.org/packages/06/7b/2ef38ed6eba80762800e5865922fb5923416d5d406a1c21d39d96988c598/mpl_scatter_density-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "93d3045c73cca1ed88531f008dd4eac6", "sha256": "0e11df89995884db0e184beb34f8aee0322eea81a13acf07a2963012da837572" }, "downloads": -1, "filename": "mpl-scatter-density-0.1.tar.gz", "has_sig": false, "md5_digest": "93d3045c73cca1ed88531f008dd4eac6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5213261, "upload_time": "2017-07-19T17:04:50", "url": "https://files.pythonhosted.org/packages/6b/42/3c312e917331124f7412c4afa29a2755dd03ad701fdc97e86e831dfc9193/mpl-scatter-density-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "bcda75024288e1996746cd32c986712a", "sha256": "24ae7c027d07b879244d75b9d2866c8f18208ff65ddf02abdd7ee9a93d67184d" }, "downloads": -1, "filename": "mpl_scatter_density-0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bcda75024288e1996746cd32c986712a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 1016157, "upload_time": "2017-07-20T09:55:52", "url": "https://files.pythonhosted.org/packages/ed/fe/a51deebeef29db13aa34f2d9d4b0370a1985d2dc35e713a7e6c36d4d5b81/mpl_scatter_density-0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4b30f9fff734637805811c93578c5171", "sha256": "c1356e2e610141569951ffa2ecde271504f4af321447e53b7bc59f2a8681b7ee" }, "downloads": -1, "filename": "mpl-scatter-density-0.2.tar.gz", "has_sig": false, "md5_digest": "4b30f9fff734637805811c93578c5171", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5356229, "upload_time": "2017-07-20T09:56:00", "url": "https://files.pythonhosted.org/packages/39/34/b059c53732817f0d35a920d4f4a8e35d153f8b94584af2f72e9af876ea5d/mpl-scatter-density-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "afc464f128487c36d3a840cf6409f391", "sha256": "43b9e1dceea65d61088140e8ad839976cfad521695350a30ac19a09d3c5af705" }, "downloads": -1, "filename": "mpl_scatter_density-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "afc464f128487c36d3a840cf6409f391", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 1727046, "upload_time": "2017-10-29T16:39:27", "url": "https://files.pythonhosted.org/packages/c0/c0/286c45fab93bb0e29a5c21259fa67f54ac402347f343f62816ae5e8659bb/mpl_scatter_density-0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "131c4ed44512e266969824024d2895e7", "sha256": "98953172aea8c652570dcc6238bccd20afb69e6ae9594d4679c08e810b658651" }, "downloads": -1, "filename": "mpl-scatter-density-0.3.tar.gz", "has_sig": false, "md5_digest": "131c4ed44512e266969824024d2895e7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6061669, "upload_time": "2017-10-29T16:39:38", "url": "https://files.pythonhosted.org/packages/56/03/30d5d902c6ae90b5413e386333532b7b1eaadb096c409fdafc84a3f6c009/mpl-scatter-density-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "db32f735b04700f3d78948ea077b04ed", "sha256": "c1c7103c683676a14ca74d1a0b8b924fb20a7359e0ce433dd4c1a3f8636bcce3" }, "downloads": -1, "filename": "mpl_scatter_density-0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "db32f735b04700f3d78948ea077b04ed", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 1729994, "upload_time": "2018-09-04T09:46:38", "url": "https://files.pythonhosted.org/packages/86/fd/b552bb556fc0e02197e85746ac389fc3b845216dacb8a213ed6f06fc9021/mpl_scatter_density-0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7b5d3e8b0773a9c2a3212de4f1d6e0e2", "sha256": "0ddffbfa0e54fb9ea0032595ef868870a77ef2e87fb1fce935527026fb01099d" }, "downloads": -1, "filename": "mpl-scatter-density-0.4.tar.gz", "has_sig": false, "md5_digest": "7b5d3e8b0773a9c2a3212de4f1d6e0e2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6185275, "upload_time": "2018-09-04T09:47:05", "url": "https://files.pythonhosted.org/packages/da/55/c15a810a6e15aa0d12ec2ba0dc444696af8576a1c17ca61d196be5070bad/mpl-scatter-density-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "a5b3e6c1acb9f2305a72317ba9d03584", "sha256": "6265c864a0d395d3f9379a4715163da2a45a438992a4fe3cebbf48274575109a" }, "downloads": -1, "filename": "mpl_scatter_density-0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a5b3e6c1acb9f2305a72317ba9d03584", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 653705, "upload_time": "2019-01-27T11:30:46", "url": "https://files.pythonhosted.org/packages/18/5d/c5450a66cb7789b0b9c569b152d24ae2b533e7386566859e7f44daebf024/mpl_scatter_density-0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d72450d193e6b7439b4f1fce557bc3fe", "sha256": "cb91fff9793655a14fedcbb36ac47e3ee67ce29119c5354e7294e41acf085a32" }, "downloads": -1, "filename": "mpl-scatter-density-0.5.tar.gz", "has_sig": false, "md5_digest": "d72450d193e6b7439b4f1fce557bc3fe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5118100, "upload_time": "2019-01-27T11:30:53", "url": "https://files.pythonhosted.org/packages/a3/6b/c1cdb24c2086944ba162671bc0652d0e4a3e224da0bf2d550531b5ccf7ad/mpl-scatter-density-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "04c41a23c8b447fa85da35dff7e42cbc", "sha256": "8c4685e66d861da2e5a9a998f27f643d4cb5f916bbaee6550398a6b8484355e9" }, "downloads": -1, "filename": "mpl_scatter_density-0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "04c41a23c8b447fa85da35dff7e42cbc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 655290, "upload_time": "2019-05-28T16:38:59", "url": "https://files.pythonhosted.org/packages/aa/01/1059e40bc71f6db8381dc5cb4135feb48d5fceff7d3b0152aa045e7c6f40/mpl_scatter_density-0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e786fd3e6c456d950baab27b3d806c1d", "sha256": "616d25a0bbbaf0f01295ab0b769180a99d09b1fdc51cfe5466a5785fe3fb5467" }, "downloads": -1, "filename": "mpl-scatter-density-0.6.tar.gz", "has_sig": false, "md5_digest": "e786fd3e6c456d950baab27b3d806c1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5118497, "upload_time": "2019-05-28T16:39:48", "url": "https://files.pythonhosted.org/packages/af/02/b033bcde00bdc0f3e017dceca16cf91f3e1b22d19d655a22c16e3554c8d1/mpl-scatter-density-0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "04c41a23c8b447fa85da35dff7e42cbc", "sha256": "8c4685e66d861da2e5a9a998f27f643d4cb5f916bbaee6550398a6b8484355e9" }, "downloads": -1, "filename": "mpl_scatter_density-0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "04c41a23c8b447fa85da35dff7e42cbc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 655290, "upload_time": "2019-05-28T16:38:59", "url": "https://files.pythonhosted.org/packages/aa/01/1059e40bc71f6db8381dc5cb4135feb48d5fceff7d3b0152aa045e7c6f40/mpl_scatter_density-0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e786fd3e6c456d950baab27b3d806c1d", "sha256": "616d25a0bbbaf0f01295ab0b769180a99d09b1fdc51cfe5466a5785fe3fb5467" }, "downloads": -1, "filename": "mpl-scatter-density-0.6.tar.gz", "has_sig": false, "md5_digest": "e786fd3e6c456d950baab27b3d806c1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5118497, "upload_time": "2019-05-28T16:39:48", "url": "https://files.pythonhosted.org/packages/af/02/b033bcde00bdc0f3e017dceca16cf91f3e1b22d19d655a22c16e3554c8d1/mpl-scatter-density-0.6.tar.gz" } ] }