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,
	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, 2023.
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.1.tar.gz (49.6 kB view details)

Uploaded Source

Built Distribution

brplotviz-0.1-py3-none-any.whl (37.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for brplotviz-0.1.tar.gz
Algorithm Hash digest
SHA256 4201b4c9e05d2586d77df3258fd67fd6fce8f90743daed1fd2737d72bc42bc34
MD5 810830894c83eefde2c6e04f16c8e242
BLAKE2b-256 a190ed86dee983d3c9b742148473bdc8082288657fd76ced722922931f034b06

See more details on using hashes here.

Provenance

File details

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

File metadata

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

File hashes

Hashes for brplotviz-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 423690e84455e6467cfaf550761c11490f1b66c318b94037057cb076b5ea0d77
MD5 07c7bfa8181eac4207fbf11352866c6d
BLAKE2b-256 aaa71d4304873235fec7c4e587eba337da95023c2b75f7dde74e9facedbfd5cd

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