Skip to main content

Logo

mpl-bsic

Create matplotlib plots in BSIC Style!

Explore the docs »

Report Bug - Request Feature

Contributors Issues License

About the Project

Plot Example

This package allows you to style matplotlib plots using BSIC Style (fonts, colors, logos, etc.) to later use them in BSIC articles. It also provides utility function to plot trades, handle the formatting of the axis, check the size of the figures, and more!

Read the sections below for an overview of how to install and use the package. For further information, be sure to read the docs!

Table Of Contents

Installation

The package supports all python versions starting from 3.9.0

To install, run

pip install mpl-bsic

Then you can import the functions from the module, for example

from mpl_bsic import apply_bsic_style

Docs and TLDR

Read the docs on this link. All the functions are explained extensively and you can find example code/plots.

WARNING: Be sure to read the docs for apply_bsic_style, and in particular how to make sure the style gets applied. You always have to make sure you call plt.show() (if in a script) even if you only plan to export the plot, since otherwise matplotlib won't run the animations which are required to apply the style to the title. And also read carefully the part about the figsize to use, especially when exporting to use in a Word file.

A brief overview of the functions of the module:

  • apply_bsic_style: applies the BSIC styles to a plot (font families, font sizes).
  • apply_bsic_logo: applies the BSIC logo to the plot. You can specify the size, location and logo type.
  • plot_trade: plots performance of the trade and path of underlying in BSIC style, with the possibility to specify additional parameters regarding formatting and visualization
  • check_figsize: checks the figsize of your plot, to make sure it will be rendered correctly in MS Word. Returns the correct figure width and height to use
  • format_timeseries_axis: formats the x axis of a timeseries plot. You can specify the time unit (yearly, monthly, daily), the frequency (e.g. a tick every 3M), and the format (e.g. MM/YYYY or MMM YYYY)
  • preprocess_dataframe: preprocesses a dataframe, by setting the index to the date (and converting to datetime) and transforming all the columns to lowercase for easier use in the project

If the matplotlib fonts do not work

Starting from version 1.2, apply_bsic_style will temporarily install the fonts (Garamond and Gill Sans MT) using FontManager in matplotlib, so that plots still get styled correctly.

For perfomance, however, this could not be the wisest choice, and you can refer to the documentation on how to properly install the fonts on your system and make them recognizable my matplotlib.

Contributing

If you have any ideas, features you would like to have implemented, or you find out any bugs within the function, be sure to open an issue and I will work on it as soon as possible. Or you can also fork the repo yourself and make a PR to the project!

Roadmap

  1. plot tables (instead of having to style them using Excel)

Metadata

Release files for mpl_bsic 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mpl_bsic 1.3.1
File Size Uploaded
mpl_bsic-1.3.1.tar.gz 5.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mpl_bsic 1.3.1
File Interpreter ABI Platform
mpl_bsic-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 MB

Release files / mpl_bsic-1.3.1.tar.gz

Download URL mpl_bsic-1.3.1.tar.gz
Size 5.1 MB
Tags Source
SHA-256 checksum
How to use checksums
19b36feac103af8bff72cb0c6d05241af9b398a3f309ebb44b62191579175384
BLAKE2b-256 checksum
How to use checksums
457dc44bb059383719a8d88873b3d10f1ad10654f6460d60b5322f18ed35ab79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.0 Windows/10

Release files / mpl_bsic-1.3.1-py3-none-any.whl

Download URL mpl_bsic-1.3.1-py3-none-any.whl
Size 5.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
51eb1ac6a02996dda3ece2e8a27ba4ffbca5923fbc7bbbdddfcfcb1c72ca8787
BLAKE2b-256 checksum
How to use checksums
a51c2927e1ed45dc39021ae6f568d9d54ef876a3a0f1e515bcad1b63ca43339a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.0 Windows/10
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page