Skip to main content

mgplot is a time-series/PeriodIndex frontend for matplotlib

Project description

mgplot

Description

mgplot is an open-source python frontend for the matplotlib package to:

  1. produce time-series charts that can be a little difficult or tricky to produce directly,
  2. finalise (or publish) charts with titles, xlabels, ylabels, etc., all while
  3. minimising code duplication, and maintaining a common plot style or look-and-feel.

Import

import mgplot as mg

Quick overview

The primary plotting functions take a pandas Series and/or DataFrame as the first argument. They all return a matplotlib Axes object. The remaining arrguments are passed as keyword arguments:

  • bar_plot() -- vertical bar plot (managers PeriodIndex date data so that not every column is labeled on the plot)
  • line_plot() -- one or more lines are ploted.
  • postcovid_plot() -- charts the data as a line, with a simple linear regression to show the pre-covid trend.
  • revision_plot() -- designed to plot a dataframe of ABS revisions.
  • run_plot() -- plots a line for a series, with background highlighting for increasing and/or decreasing runs.
  • seastrend_plot() -- plots seasonal and trend data on the one plot.
  • series_growth_plot() -- combines annual and quarterly/monthly growth on the same plot using a line for annual growth and bars for quarterly growth.
  • summary_plot() -- plots the latest data in a summary-format against the range of previous data.

Once a plot has been generated and an Axes object is available. The plot can be finalised or published, with appropriate titles and axis labels using

  • finalise_plot()

You can chain the development of plots together with functions designed for this purpose. In addition to a required data argument, each of these functions also has a required function argument which is either a single function or a list of functions.

  • multi_start() -- takes a starts argument, and calls the next function (repeatedly if necessary) with the plot_from argument set to the one or more starts provided.
  • multi_column() -- calls the next function repeatedly, with the data set to a single column of its DataFrame.
  • plot_the_finalise() -- calls the specified plot function, and then calls the finalise_plot() function.

Finally, for every plot function above, there is a convenience function that automatically calls both the plot function and then the finalise_plot() function:

  • bar_plot_finalise() -- calls bar_plot() then finalise_plot()
  • line_plot_finalise()
  • postcovid_plot_finalise()
  • revision_plot_finalise()
  • run_plot_finalise()
  • seastrend_plot_finalise()
  • series_growth_plot_finalise()
  • summary_plot_finalise()

For more details, see the documentation folder.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mgplot-0.2.15.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mgplot-0.2.15-py3-none-any.whl (47.6 kB view details)

Uploaded Python 3

File details

Details for the file mgplot-0.2.15.tar.gz.

File metadata

  • Download URL: mgplot-0.2.15.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for mgplot-0.2.15.tar.gz
Algorithm Hash digest
SHA256 5af0ca1d788b2f49746d1d6c8d0076f8da986851d5aec717330d9f031848cd89
MD5 efb5d24eb4fb1661b2e74bbf26d4f611
BLAKE2b-256 c6a389f4d540f3a202513fb6430408d97560ee549e86701bd6c1dd6963293d7e

See more details on using hashes here.

File details

Details for the file mgplot-0.2.15-py3-none-any.whl.

File metadata

  • Download URL: mgplot-0.2.15-py3-none-any.whl
  • Upload date:
  • Size: 47.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for mgplot-0.2.15-py3-none-any.whl
Algorithm Hash digest
SHA256 388b3fbb8830be118c9fdb45bd781a9fe3be5c18a541befa8bdea1f928aa7b67
MD5 f7fac090c700bbb06094f881d445a2ef
BLAKE2b-256 5bc4ac0214e4c9a0e75aa79d4fa36dd5fe51d23b8930a4e01e570b523f8b02ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page