{ "info": { "author": "Paul Gowder", "author_email": "paul.gowder@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only" ], "description": "Plottyprint\n===========\n\nThe Goal\n--------\n\nMake simple data visualizations in Python that are **easy**,\n**attractive**, and most importantly **appropriate for dead-tree\nprinting** (like in academic journals, conference posters, or\nnewspapers), with a bias toward greyscale in case color printing is\nexpensive (or just not allowed).\n\nThis very small library is targeted at the easiest 60% or so of plots\nthat social scientists and student journalists and other\nlight-to-moderate data users will want to produce.\n\nRight now, the amount of effort it takes to go from from no plots at all\nor really ugly plots to simple but attractive plots is *much* longer\nthan the amount of effort from simple but attractive plots to really\ncomplex plots. This strikes me as unacceptable. If you want to produce a\n4-d contour plot overlaid on a map of the world with color representing\ntime, I can\u2019t help you. But if you want to produce a basic scatterplot,\nmaybe with a least squares fit on top of it, and then slap it into your\njournal submission to impress the peer reviewers, I\u2019m here for you.\n\nThe Challenges\n--------------\n\n1. Default matplotlib plotting is ugly, and making attractive plots is\n difficult.\n\n2. There are many Python packages that make it easy create beautiful\n plots on top of Matplotlib, such as\n `Seaborn `__,\n `Bokeh `__, and\n `Plotly `__ are my favorite examples, but\n the readme to `Altair `__ lists\n numerous other excellent options. However, these options are all\n built for web or interactive use, not for printing. They have lots of\n colors, default proportions appropriate for screen usage, and often\n interactive elements that don\u2019t make sense on paper. While it\u2019s\n possibly to convince those libraries to make plots for print, it\u2019s a\n lot of work. (If you want to do that, I recommend using the Python\n port of `ggplot `__ or the plotting\n convenience functions `in Pandas `__.)\n\nThe Plottyprint Solution\n------------------------\n\nThis very small library aims to provide a handful of basic and\nattractive printable plots that will work out of the box with sensible\ndefaults for the most simple use cases. Right now, it supplies four\nworkhorse plots:\n\n1. A **scatterplot** between two variables. By default, the scatterplot\n has a least squares line through it, and a confidence region around\n that line, but this is easy to turn off.\n\n2. A **histogram** of one variable. If you want to get really fancy to\n impress the peer reviewers, you can stick a kernel density estimator\n line on top of it.\n\n3. A **boxplot** with the standard frills (whiskers, notches, all that\n good stuff).\n\n4. A **time series plot** that gives you a line of one or two events\n over time. The time series plot is experimental, and might not work\n with your data; I\u2019ll try to improve it in subsequent versions.\n\nThis, obviously, represents the science communicator\u2019s basic toolkit for\ndisplaying the relationship between two variables, the shape of one\nvariable, the relationship between mean, interquartile range, and\noutliers for several variables, and variable behavior over time,\nrespectively.\n\nEach of these elements is presented in high-contrast greyscale, and has\nall of matplotlib\u2019s default `chart\njunk `__ ruthlessly ripped\nout.\n\nIn this 0.1 release, there are only a handful of customization options,\nbut over time I plan to add more plot types and add a bit more\ncustomization. Moreover, every plot returns a (subclass of a) Matplotlib\nfigure, so if you know matplotlib you can always do your own\ncustomization after the fact.\n\nHere are some examples.\n\nScatterplot, with fit line and confidence region.\n\n.. figure:: scatterplot.svg\n :alt: scatterplot\n\n\nHistogram, no KDE estimator.\n\n.. figure:: histogram_simple.svg\n :alt: simple histogram\n\n\nHistogram, with KDE estimator\n\n.. figure:: histogram_fancy.svg\n :alt: fancy histogram\n\n\nBoxplot\n\n.. figure:: boxplot.svg\n :alt: boxplot\n\n\nTime Series\n\n.. figure:: timeseries.svg\n :alt: time series\n\n\nInstallation\n------------\n\n``pip install plottyprint``\n\nUsage\n-----\n\nThere are three functions, each corresponding to a plot. Each takes one\nor more Numpy arrays, or anything that can be cast into a Numpy array\nwith ``np.array()`` without going wrong (lists, Pandas ``DataFrame``\ncolumns, etc.), plus some configuration.\n\nEach function returns a ``PlottyFig`` object. This is just a subclass of\n``matplotlib.figure.Figure``, with a handful of convenience methods\n(documented below) to tweak your plots after you create them and smooth\nout the rough edges of the Matplotlib api. Because it\u2019s a figure\nsubclass, those who know Matplotlib can also dig in deeper to tweak to\nyour heart\u2019s content.\n\nScatterplot\n~~~~~~~~~~~\n\n**scatterplot(x, y, title=\u201c\u201d, xlabel=\u201c\u201d, ylabel=\u201c\u201d, numticks=3,\nlabelsize=15, dotsize=8, ylabel_wrapping=6, size=(10, 10),\nfit_line=True, confidence=True, alpha=0.05, font=\u201cLato\u201d)**\n\n- x and y are, obviously, your data.\n\n- title is, obviously, the title of the plot\n\n- xlabel and ylabel are, obviously, the labels for your data.\n\n- numticks is (wait for it) the number of ticks to show on each axis.\n For mysterious reasons, sometimes Matplotlib likes to give you a\n little more or fewer than the number asked for, but at any rate the\n default is a nice small number that will show the scale of the data\n without overwhelming the reader with noise.\n\n- labelsize is the size of the axis labels. The title will be scaled up\n a little from this.\n\n- dotsize is the size of the individual points in the plot.\n\n- ylabel_wrapping is the number of characters in the y label before it\n wraps to another line. (Making y labels attractive is a bit\n difficult.)\n\n- size is a tuple representing the size in inches\n\n- fit_line is a boolean representing whether or not to put a least\n squares line in the plot.\n\n- confidence is a boolean representing whether or not to put a\n confidence interval around the least squares line. Obviously, this\n won\u2019t do anything if you don\u2019t have a least squares line in there.\n\n- alpha is the width of your confidence interval. The default\n represents the good old fashioned 95% interval.\n\n- font is the name of the font for labels. See below for some caveats on this.\n\nHistogram\n~~~~~~~~~\n\n**histogram(variable, bins=\u201cauto\u201d, density = False, title=\u201c\u201d,\nnumticks=5, labelsize=15, size=(10, 10), add_kde=False, kernel_param =\n0.4, show_n = True, font=\u201cLato\u201d)**\n\n- variable is, obviously, your data.\n\n- bins can be a number of bins, or \u201cauto\u201d to let numpy come up with\n something for you\n\n- add_kde controls whether you want to slap a kernel density estimator\n plot on top of your histogram. If you do want to do this, it\u2019ll\n change the scale of the histogram: it will become probability density\n rather than counts, and, since the y label on a density histogram is\n anywhere between confusing and outright deceptive, it gets removed.\n Call me paternalistic.\n\n- kernel_param is a parameter that goes into the kernel density\n estimator. Scipy does `a lot of fancy\n math `__\n with this, but you can think of it as kind of similar to the\n bandwidth parameter in the `R kde\n function `__.\n For practical purposes, larger numers should produce smoother plots,\n but it\u2019s probably worth playing with interactively.\n\n- show_n is a boolean determining whether to show the number of\n observations as a label below the x axis or not.\n\nEverything else is the same as in ``scatterplot``.\n\nBoxplot\n~~~~~~~\n\n**boxplot(variables, labels, title=\u201c\u201d, numticks=3, labelsize=14,\nsize=(10, 10), font=\u201cLato\u201d)**\n\nEverything here is the same as in ``scatterplot`` except that variables\nis a list of, well, variables (numpy arrays etc.), and labels is a list\nof labels. You can put as many variables in here as you can squeeze in.\n\nTime Series\n~~~~~~~~~~~\n\n**timeseries(in_dates, events, labels = [\u201c\u201d, \u201c\u201d], title=\u201c\u201d, numticks=3,\nlabelsize=12, size=(10, 10), font=\u201cLato\u201d, notch=True)**\n\n- in_dates is an array (or list etc.) of ``date`` objects (from the\n standard Python datetime module).\n\n- events is a list of arrays of events. There can be a maximum of\n two\u2014each of these will be plotted as a different line. (So, in_dates\n will be a column of your data, and events will be a list of one or\n two columns from your data.)\n\n- labels is, like in boxplot, a list of labels for your events.\n\n- notch is whether to put a notch in the boxes marking out a confidence\n interval around the median. Uses the Matplotlib default, which isn\u2019t\n terribly clearly specified in `the\n documentation `__,\n but I assume (from the bootstrap parameter in there) is 95%.\n\nOtherwise, the parameters are the same as above. However, you should\nnote that numticks doesn\u2019t control the number of entries on the x axis\n(time). Messing with that is actually a terribly gnarly procedure, but\nthe defaults seem to be working.\n\nPlottyFig Object\n~~~~~~~~~~~~~~~~\n\nAs noted above, the PlottyFig object supplies several convenience\nmethods, which can be called on any instance generated by this library\n(denoted ``instance`` below), including:\n\n**instance.get_main_plot()** returns the Matplotlib ``Axes`` object\ncontaining the actual plot\u2014this is where you do things like change the\ntitle, tweak borders, fonts, etc., or, for more advanced uses, overlay\nplots of extra data onto the existing axis and suchlike. Mutating the object returned by this function should mutate the underlying figure.\n\n**instance.get_lines()** returns a list of the lines that make up the\nplot.\n\n**instance.change_title(title)** changes the title of an existing plot.\n\n**instance.set_line_width(width)** sets the width of the lines in the\nplot.\n\nRight now, this class is a stub for future development: I like the idea\nof smoothing out the Matplotlib api a little, but don\u2019t know what\nconvenience methods would be most useful. More to be added in future\nversions.\n\nPossible Glitches\n-----------------\n\n- This requires python 3, and a recent version of Matplotlib.\n I've tested it in Python 3.6.4 with Matplotlib 2.1.2.\n In particular, if ``histogram`` breaks, or if ``scatterplot``\n produces strange lines around the confidence bands, that's\n going to be an obsolete Matplotlib version.\n\n- Fonts are a problem with Matplotlib, and if you run into font\n difficulties then see `this blog\n post `__ for\n a fix. I\u2019ve set Lato as the font for everything because it\u2019s pretty\n and `on google fonts `__.\n\n- I haven\u2019t quite sorted out timeseries date ranges yet. Right now it\n just uses the Matplotlib defaults, and uses the ordinary plotting\n method rather than the ``plot_date`` method to generate\n (``plot_date`` produces mysterious and bizarre results). A PR to make\n this a little nicer would be very welcome.\n\nContributing\n------------\n\nJust file an issue or a PR.\n\nCurrent priorities include:\n\n1. Making the time series better, particularly with respect to\n customization options for the x axis ticks.\n\n2. Some way to apply the stylistic choices in here to plots generated\n from other libraries like Seaborn (perhaps a Matplotlib stylesheet,\n or some heavy hacking around with rcparams).\n\n3. Tests. (Maybe by comparing function results against a SVG string?)\n\n4. More useful ``PlottyFig`` convenience methods.\n\n5. A scatterplot matrix (like the one produced by Pandas).\n\nLicense\n-------\n\nMIT.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/paultopia/plottyprint", "keywords": "plotting,datavis", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "plottyprint", "package_url": "https://pypi.org/project/plottyprint/", "platform": "", "project_url": "https://pypi.org/project/plottyprint/", "project_urls": { "Homepage": "https://github.com/paultopia/plottyprint" }, "release_url": "https://pypi.org/project/plottyprint/0.1/", "requires_dist": [ "numpy", "matplotlib (>=2.1.1)", "statsmodels", "scipy" ], "requires_python": ">=3", "summary": "provide a couple of easy to use, very basic, printable plots on top of matplotlib", "version": "0.1" }, "last_serial": 3636013, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "c4e519409a27a96a62b60591871e93ef", "sha256": "2f25881785870dfc450ba259ff1d127f2ff0ffbf95196f6694760d48d8991740" }, "downloads": -1, "filename": "plottyprint-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c4e519409a27a96a62b60591871e93ef", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 16283, "upload_time": "2018-03-04T01:15:44", "url": "https://files.pythonhosted.org/packages/92/25/30d42a989117df1945ec4c15b676347f48e652adddd732fd154a09b53766/plottyprint-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "76b5fbe8186c661798fb0515473c889b", "sha256": "886e8284f3d6d4efede43057fe774850ee2ea4bc0d868c74d93f856e1ee69d73" }, "downloads": -1, "filename": "plottyprint-0.1.tar.gz", "has_sig": false, "md5_digest": "76b5fbe8186c661798fb0515473c889b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 53643, "upload_time": "2018-03-04T01:15:47", "url": "https://files.pythonhosted.org/packages/78/41/04798faee08d689ad65dc3ab235b717b6a81b566b8de04cd087d8a1b1d9c/plottyprint-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c4e519409a27a96a62b60591871e93ef", "sha256": "2f25881785870dfc450ba259ff1d127f2ff0ffbf95196f6694760d48d8991740" }, "downloads": -1, "filename": "plottyprint-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c4e519409a27a96a62b60591871e93ef", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 16283, "upload_time": "2018-03-04T01:15:44", "url": "https://files.pythonhosted.org/packages/92/25/30d42a989117df1945ec4c15b676347f48e652adddd732fd154a09b53766/plottyprint-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "76b5fbe8186c661798fb0515473c889b", "sha256": "886e8284f3d6d4efede43057fe774850ee2ea4bc0d868c74d93f856e1ee69d73" }, "downloads": -1, "filename": "plottyprint-0.1.tar.gz", "has_sig": false, "md5_digest": "76b5fbe8186c661798fb0515473c889b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 53643, "upload_time": "2018-03-04T01:15:47", "url": "https://files.pythonhosted.org/packages/78/41/04798faee08d689ad65dc3ab235b717b6a81b566b8de04cd087d8a1b1d9c/plottyprint-0.1.tar.gz" } ] }