Skip to main content

Plot utilities for outputting plots and tables nicely formatted

Project description

brplotviz are plot utilities for outputting plots using matplotlib and nicely formatted tables according to the personal taste of Bertram Richter.

Getting started

This package provides functions to simplify the output of nicely fomatted graphs. The main focus is to enable consistent graphical style suited for printing. Thus, a monochrome (black-white) style is used.

Let's start plotting. First, we need some data:

import numpy as np
import brplotviz
x_list = np.linspace(0, 2, 17)
y_list_sin = np.sin(x_list)
y_list_cos = np.cos(x_list)
x_table = [x_list, x_list]
y_table = [y_list_sin, y_list_cos]
record_names = ["sine", "cosine"]

Plotting a single line-graph and a scatter plot is as simple as:

brplotviz.plot.single_line(x_list, y_list_sin)
brplotviz.plot.single_scatter(x_list, y_list_sin)

Plotting several line plots or mutliple scatter plots is:

brplotviz.plot.multi_line(x_table, y_table, record_names)
brplotviz.plot.multi_scatter(x_table, y_table, record_names)

To mix line and scatter plot we need to construct a list of data record tuples first:

record_list = [(x_list, y_list_sin, "scatter", {"label": "sine"}), (x_list, y_list_cos, "line", {"label": "cosine"})]
brplotviz.plot.mixed_graphs(record_list)

Finally, let's plot a bar chart first with one data record, then with multiple records:

brplotviz.plot.bar_categories([y_list_sin], category_names=x_list)
brplotviz.plot.bar_categories(y_table, category_names=x_list)

Plotting graphs is not the only thing, which can be done with brplotviz. Presenting data in tabular form is also supported. The killer feature here are the possibilities to format the entries either alltogether or each one separately.

brplotviz.table.print_table(
	table=y_table,
	engine="csv",
	head_row=x_list,
	head_col=record_names,
	top_left="Values",
	caption="Sine and cosine Values",
	formatter=":.2f",
	)

We can put out the table formatted as a LaTeX table as well. After copying into a .tex file and compiling it with LaTeX, it is typeset with professional quality. For this to work, follow the additional steps as described in \ref brplotviz.table.print_table_LaTeX().

brplotviz.table.print_table_LaTeX(
	table=y_table,
	head_row=x_list,
	head_col=record_names,
	top_left="Values",
	formatter=":.2f",
	caption="Sine and cosine Values",
	LaTeX_label="sinecosine",
	)

The content can be written to disk, if the keyword argument file=<file path here> is passed, which works for all presented functions. Warning: the file is overwritten without further questions.

All of the presented functions are compiled in \ref example.py ready to run.

Installation and Building documentation

Install this package via pip install -U brplotviz. To build the documentation, run doxygen in this directory to generate it to the directory ./Documentation

Licence and Copyright

Author: Bertram Richter
Copyright: Copyright by the author, 2024.
License: This software is released under GPLv3, see LICENSE for details

Dependencies

  • Python >=3.? (Developed under Python 3.9)
  • matplotlib >=3.5.0 for plotting and drawing graphs. See matplotlib.org for the documentation.
  • numpy for array operations. See numpy.org for the documentation.

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

brplotviz-0.2.2.tar.gz (53.2 kB view details)

Uploaded Source

Built Distribution

brplotviz-0.2.2-py3-none-any.whl (41.9 kB view details)

Uploaded Python 3

File details

Details for the file brplotviz-0.2.2.tar.gz.

File metadata

  • Download URL: brplotviz-0.2.2.tar.gz
  • Upload date:
  • Size: 53.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for brplotviz-0.2.2.tar.gz
Algorithm Hash digest
SHA256 b8769954ba8202e9d82d5c59401e44772483d2c9620a674b599d1326ae56f1ef
MD5 abbf79d5ef80b5c6479b5f0733b9c4b6
BLAKE2b-256 6a65373e15d21aae9a169fa1dba633c4000f040a85f56d878800a5b20f924d62

See more details on using hashes here.

Provenance

File details

Details for the file brplotviz-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: brplotviz-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 41.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for brplotviz-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 237c6b2fdfea98cc00158eb731a8388ac674ce6c8cedac790b66e52b3d611ef6
MD5 21bc07031f533fc7aae5e0f4ee6a0408
BLAKE2b-256 7a07086cd06dc07ace73ede373f9ded88f5fb087ea11c5d1e488ee625fe806e8

See more details on using hashes here.

Provenance

Supported by

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