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.17.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.17-py3-none-any.whl (47.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mgplot-0.2.17.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.17.tar.gz
Algorithm Hash digest
SHA256 b36f40509886dc2814248775b5a83154ffecba7b13a6ed31f1f7d27c2cc27bad
MD5 fb8c1110f6ffc5d7d5e4982b866476f9
BLAKE2b-256 e7374b68b0eabcbb41a79b8eb5957f17e45a7a763f2e77f8962f42b737929979

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mgplot-0.2.17-py3-none-any.whl
Algorithm Hash digest
SHA256 c83b12cb295b794a8f3af33b289a4c9853e6389a6fb4e7453f2b8422fcf22b61
MD5 cb90638d2092c104fd478679e7536fe3
BLAKE2b-256 fd5677f2cf6d10967caacc80cb4c1ffcbd46d5f3f54fabdeb0facc7f5296ab02

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