Skip to main content

Implementation of Matplotlib in Flask

Project description

Flask-Plots

Build status codecov docs docstr-cov License Forks Stars Issues black https://github.com/leliel12/diseno_sci_sfw

Flask-Plots is a library for creating and rendering static visualizations using Matplotlib in Python.

Requirements

Python 3.8+

Dependecies for this project.

intallation

You can install via pip:

    $> pip install Flask-Plots

For development, clone the official github repository instead and use:

    $ git clone git@github.com:juniors90/Flask-Plots.git
    $ cd Flask-Plots
    $ python3 -m venv venv
    $ source venv/bin/activate
    (venv) $ pip install -r requirements/dev.txt

Quick start

With Flask-Plots you can instance the Plots object and document your endpoints.

    from flask import Flask, render_template_string
    from flask_plots import Plots
    import matplotlib
    from matplotlib.figure import Figure
    import numpy as np
    
    app = Flask(__name__)
    plots = Plots(app)

    # routes
    @app.route("/")
    def bar():
        # Make data:
        countries = ["Argentina", "Brasil", "Colombia", "Chile"]
        peoples = [14, 40, 16, 24]
        # Plot:
        fig = Figure()
        ax = fig.subplots()
        ax = plots.bar(fig, countries, peoples)
        ax.set_title("Bar Chart")
        data = plots.get_data(fig)
        return render_template_string(
                """
                {% from 'plots/utils.html' import render_img %}
                {{ render_img(data=data, alt_img='my_img') }}
                """,
                data=data
            )

    if __name__ == "__main__":
        app.run(port=5000, debug=True)

Links

Authors

  • Ferreira, Juan David

Please submit bug reports, suggestions for improvements and patches via the (E-mail: juandavid9a0@gmail.com).

Official repository and Issues

Acknowledgment

Thank you to Juan B. Cabral, and Martin Chalela for his teachings during Curso doctoral FAMAF: Diseño de software para cómputo científico, from which this library is based.

License

Flask-Plots is free software you can redistribute it and/or modify it under the terms of the MIT License. For more information, you can see the LICENSE file for details.

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

Flask-Plots-0.0.1.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

Flask_Plots-0.0.1-py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 3

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