Curvipy - The Python package for visualizing curves and linear transformations in a super simple way

Overview

curvipy 📐

licence

The Python package for visualizing curves and linear transformations in a super simple way.

✏️ Installation

Install curvipy package with pip:

$ pip install curvipy

or clone the repository:

$ git clone https://github.com/dylannalex/curvipy.git

✏️ Basic usage

This is a simple use guide. You can see all curvipy functionalities at curvipy documentation.

📌 Drawing curves

To start drawing curves you need to create a GraphingCalculator object:

from curvipy import GraphingCalculator

graphing_calculator = GraphingCalculator()

curvipy let you draw parametrized curves and mathematical functions. Lets create and draw the square root of x function for this example:

def square_root(x):
    return x ** (1 / 2)

graphing_calculator.draw(square_root, (0, 25))  # We want to draw the function from x = 0 to x = 25

You can also accomplish the same result by defining the square root of x as a parameterized function:

def square_root(t):
    return t, t ** (1 / 2)

graphing_calculator.draw(square_root, (0, 25))  # We want to draw the curve from t = 0 to t = 25

📌 Linear transformations

curvipy provides a curves module which contains functions for modifying curves with linear transformations.

from curvipy import curves

📍 curves.transform_curve()

This function let you apply a linear transformation (specified as a matrix) to a parametrized curve. curves.transform_curve() returns the transformed curve.

Parameters:

  • curve: parametrized curve
  • matrix: linear transformation's matrix

The matrix is a tuple of tuples (or list of lists) which has the same structure as numpy arrays. A matrix
[ a b ]
[ c d ]
should be defined as:

matrix = ((a,b), (c,d))

Example:

matrix = ((1, 0), (0, -2))
graphing_calculator.draw(curves.transform_curve(square_root, matrix), (0, 25))

📍 curves.rotate_curve()

Rotates a curve anticlockwise by the given angle.

Parameters:

  • curve: parametrized curve
  • angle: angle in radians
    Example:
angle = pi / 4  # 90 degrees
graphing_calculator.draw(curves.rotate_curve(square_root, angle), (0, 25))

📍 curves.scale_curve()

Scales the given curve by the given scalar.

Parameters:

  • curve: parametrized curve
  • scalar: scalar for scaling the curve
    Example:
scalar = 2  # The function is going to be twice as bigger
graphing_calculator.draw(curves.scale_curve(square_root, 2), (0, 25))
Comments
  • Update Latex expressions

    Update Latex expressions

    Some changes might feel unnecessary, but I felt like it would be better to have those changes. Like the more conventional font for real number set or the extra line of explanation for linear transformation.

    opened by ritamsaha00 8
  • v1.1.0

    v1.1.0

    • Updated plotter:
      • 'curvipy.Plotter' now draws axes ticks and arrows (to indicate the axis direction).
      • Removed 'interval: curvipy.Interval' parameter of 'curvipy.Plotter.plot_curve()' and 'curvipy.Plotter.plot_animated_curve()' methods.
      • 'curvipy.Plotter.plot_vector()' can now display vector's components.
      • Created 'curvipy.PlottingConfiguration' and 'curvipy.AxesConfiguration'
        • Updated 'curvipy.Plotter' builder parameters to 'curvipy.Plotter(window_title: str = "Curvipy", background_color: str = "#FFFFFF", plotting_config: PlottingConfiguration, axes_config: AxesConfiguration)'.
        • Now 'x_axis_scale' and 'y_axis_scale' (defined at curvipy.AxesConfiguration') can take any real value (negative or positive) and default to one.
    • Updated vector:
      • Added vector, addition, subtraction, scaling and equality.
      • Created 'curvipy.Vector.place()' method which moves the vector to a specified set of coordinates.
    • Updated curves:
      • Removed 'interval: curvipy.Interval' parameter of 'curvipy.Curve.points()' method.
      • Added 'interval: curvipy.Interval' parameter to 'curvipy.Function' and 'curvipy.ParametricFunction' builder.
    • Updated documentation.
    opened by dylannalex 0
  • Show numbers on the x and y axes

    Show numbers on the x and y axes

    A few aspects to keep in mind:

    • Number shown depend on 'curvipy.Plotter.x_axis_scale' and 'curvipy.Plotter.y_axis_scale'.
    • Add a new 'curvipy.Plotter' attribute to indicate the quantity of numbers to be displayed on the axes.
    • Add a method 'curvipy.ScreenFacade' to display text on screen. This method will be used by 'curvipy.Plotter' to display the numbers on the axes.
    enhancement 
    opened by dylannalex 0
  • Add vector addition and subtraction operations.

    Add vector addition and subtraction operations.

    Given the vectors $\vec{v}$ and $\vec{w}$, we want to compute $\vec{n} = \vec{v} + \vec{w}$ and $\vec{m} = \vec{v} - \vec{w}$ as shown below:

    import curvipy
    
    v = curvipy.Vector([10, 10])
    w = curvipy.Vector([5, -5])
    n = v + w
    m = v - w
    

    This is not possible on Curvipy 1.0.1. To do so, users have to calculate $\vec{n}$ and $\vec{m}$ manually:

    import curvipy
    
    v = curvipy.Vector([10, 10])
    w = curvipy.Vector([5, -5])
    n = curvipy.Vector([10 + 5, 10 + (-5)])
    m = curvipy.Vector([10 - 5, 10 - (-5)])
    
    enhancement 
    opened by dylannalex 0
  • Add an 'exclude' parameter to 'curvipy.Interval'

    Add an 'exclude' parameter to 'curvipy.Interval'

    The idea is to exclude a list of values from the interval, so they won't be considered when plotting the curve.

    curvipy.Interval:
        Parameters
        ----------
        start : int or float
            Real number in which the interval starts.
        end : int or float
            Real number in which the interval ends.
        samples: int
            Number of values within the interval. The more samples, the more precise the \
            curve plot is.
        exclude: list[int or float]
            List of values that will be excluded from the interval.
    

    Example: imagine we want to plot the curve $f(x) = 1/x$ on the interval $x \in [-a, a]$. Since $f(0)$ is not defined, the current way of doing that is to create two intervals:

    import curvipy
    
    
    def f(x):
        return 1 / x
    
    
    plotter = curvipy.Plotter()
    
    a = 10
    curve = curvipy.Function(f)
    interval_one = curvipy.Interval(-a, -0.1, 100)
    interval_two = curvipy.Interval(0.1, a, 100)
    
    plotter.plot_curve(curve, interval_one)
    plotter.plot_curve(curve, interval_two)
    plotter.wait()
    

    With an 'exclude' parameter on 'curvipy.Interval' class, we could accomplish the same goal with only one interval:

    import curvipy
    
    
    def f(x):
        return 1 / x
    
    
    plotter = curvipy.Plotter()
    
    a = 10
    curve = curvipy.Function(f)
    interval = curvipy.Interval(-a, a, 200, exclude=[0])
    
    plotter.plot_curve(curve, interval)
    plotter.wait()
    

    If somebody wants to work on it, please make a comment. Implementing this is not as easy as it seems and might need modifications in other classes like curvipy.Plotter and/or curvipy.Curve.

    enhancement wontfix 
    opened by dylannalex 0
  • 1.0.1

    1.0.1

    This update brings a structure improvement and better documentation. Curvipy 1.0.0 scripts are completely compatible with this new version:

    • Made modules private. Now importing curvipy will only import its classes.
    • Created 'curvipy._screen' module. This module contains the 'ScreenFacade' class which encapsulates the turtle package functionalities.
    • Updated documentation.
    opened by dylannalex 0
  • Bump to 1.0.0

    Bump to 1.0.0

    • Added 'curvipy.curve' module. This module contains the classes:
      • 'Curve': base class for all two-dimensional curves.
      • 'Function': unction that given a real number returns another real number.
      • 'ParametricFunction': function that given a real number returns a 2-dimensional vector.
      • 'TransformedCurve': applies a linear transformation to the given curve.
    • Added 'curvipy.interval' module. This module contains the class 'Interval', which is the interval in which a curve will be plotted.
    • Added 'curvipy.vector' module. This module contains the class 'Vector', which is a two-dimensional vector.
    • Updated 'curvipy.graphing_calculator' module (now named 'curvipy.plotter'):
      • Renamed 'curvipy.graphing_calculator' to 'curvipy.plotter' and its class 'GraphingCalculator' to 'Plotter'.
      • Replaced methods 'draw_vector', 'draw_curve' and 'draw_animated_curve' with 'plot_vector', 'plot_curve' and 'plot_animated_curve' respectively.
    • Deleted 'curvipy.lintrans' module. Linear transformations can now be defined with 'curvipy.TransformedCurve' class.
    • Updated README and docs.
    • Deleted 'examples' folder since README and docs now contains a Usage Example section.
    opened by dylannalex 0
  • Update GIFs from docs/source/img for curvipy v1.1.0

    Update GIFs from docs/source/img for curvipy v1.1.0

    GIFs shown on documentation (both README and docs) are from curvipy v1.0.1. To update the animations, just run the code shown above the GIF and record the screen with some third party software (e.g. ActivePresenter).

    documentation good first issue 
    opened by dylannalex 0
  • A rotation function

    A rotation function

    A function that rotates the curve by a certain $\theta$ angle. The implementation is easy, it will take $\theta$, and the curve as input, and method is just like TransformedCurve, but the matrix used will be:

    $$A(\theta)=\begin{pmatrix} \cos\theta & -\sin\theta\ \sin\theta & \cos\theta \end{pmatrix}$$

    enhancement good first issue 
    opened by ritamsaha00 2
Releases(1.1.0)
  • 1.1.0(Dec 28, 2022)

    • Updated plotter:
      • 'curvipy.Plotter' now draws axes ticks and arrows (to indicate the axis direction).
      • Removed 'interval: curvipy.Interval' parameter of 'curvipy.Plotter.plot_curve()' and 'curvipy.Plotter.plot_animated_curve()' methods.
      • 'curvipy.Plotter.plot_vector()' can now display vector's components.
      • Created 'curvipy.PlottingConfiguration' and 'curvipy.AxesConfiguration'
        • Updated 'curvipy.Plotter' builder parameters to 'curvipy.Plotter(window_title: str = "Curvipy", background_color: str = "#FFFFFF", plotting_config: PlottingConfiguration, axes_config: AxesConfiguration)'.
        • Now 'x_axis_scale' and 'y_axis_scale' (defined at curvipy.AxesConfiguration') can take any real value (negative or positive) and default to one.
    • Updated vector:
      • Added vector, addition, subtraction, scaling and equality.
      • Created 'curvipy.Vector.place()' method which moves the vector to a specified set of coordinates.
    • Updated curves:
      • Removed 'interval: curvipy.Interval' parameter of 'curvipy.Curve.points()' method.
      • Added 'interval: curvipy.Interval' parameter to 'curvipy.Function' and 'curvipy.ParametricFunction' builder.
    • Updated documentation.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Nov 28, 2022)

    This update brings a structure improvement and better documentation. Curvipy 1.0.0 scripts are completely compatible with this new version:

    • Made modules private. Now importing curvipy will only import its classes.
    • Created 'curvipy._screen' module. This module contains the 'ScreenFacade' class which encapsulates the turtle package functionalities.
    • Updated documentation.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Oct 22, 2022)

    • Added 'curvipy.curve' module. This module contains the classes:
      • 'Curve': base class for all two-dimensional curves.
      • 'Function': unction that given a real number returns another real number.
      • 'ParametricFunction': function that given a real number returns a 2-dimensional vector.
      • 'TransformedCurve': applies a linear transformation to the given curve.
    • Added 'curvipy.interval' module. This module contains the class 'Interval', which is the interval in which a curve will be plotted.
    • Added 'curvipy.vector' module. This module contains the class 'Vector', which is a two-dimensional vector.
    • Updated 'curvipy.graphing_calculator' module (now named 'curvipy.plotter'):
      • Renamed 'curvipy.graphing_calculator' to 'curvipy.plotter' and its class 'GraphingCalculator' to 'Plotter'.
      • Replaced methods 'draw_vector', 'draw_curve' and 'draw_animated_curve' with 'plot_vector', 'plot_curve' and 'plot_animated_curve' respectively.
    • Deleted 'curvipy.lintrans' module. Linear transformations can now be defined with 'curvipy.TransformedCurve' class.
    • Updated README and docs.
    • Deleted 'examples' folder since README and docs now contains a Usage Example section.
    Source code(tar.gz)
    Source code(zip)
Owner
Dylan Tintenfich
:books: Systems engineering student at Universidad Tecnológica Nacional Mendoza.
Dylan Tintenfich
Generate a roam research like Network Graph view from your Notion pages.

Notion Graph View Export Notion pages to a Roam Research like graph view.

Steve Sun 214 Jan 07, 2023
A python script to visualise explain plans as a graph using graphviz

README Needs to be improved Prerequisites Need to have graphiz installed on the machine. Refer to https://graphviz.readthedocs.io/en/stable/manual.htm

Edward Mallia 1 Sep 28, 2021
A simple Monte Carlo simulation using Python and matplotlib library

Monte Carlo python simulation Install linux dependencies sudo apt update sudo apt install build-essential \ software-properties-commo

Samuel Terra 2 Dec 13, 2021
Plot-configurations for scientific publications, purely based on matplotlib

TUEplots Plot-configurations for scientific publications, purely based on matplotlib. Usage Please have a look at the examples in the example/ directo

Nicholas Krämer 487 Jan 08, 2023
Automatization of BoxPlot graph usin Python MatPlotLib and Excel

BoxPlotGraphAutomation Automatization of BoxPlot graph usin Python / Excel. This file is an automation of BoxPlot-Graph using python graph library mat

EricAugustin 1 Feb 07, 2022
Sprint planner considering JIRA issues and google calendar meetings schedule.

Sprint planner Sprint planner is a Python script for planning your Jira tasks based on your calendar availability. Installation Use the package manage

Apptension 2 Dec 05, 2021
Material for dataviz course at university of Bordeaux

Material for dataviz course at university of Bordeaux

Nicolas P. Rougier 50 Jul 17, 2022
ecoglib: visualization and statistics for high density microecog signals

ecoglib: visualization and statistics for high density microecog signals This library contains high-level analysis tools for "topos" and "chronos" asp

1 Nov 17, 2021
Python scripts for plotting audiograms and related data from Interacoustics Equinox audiometer and Otoaccess software.

audiometry Python scripts for plotting audiograms and related data from Interacoustics Equinox 2.0 audiometer and Otoaccess software. Maybe similar sc

Hamilton Lab at UT Austin 2 Jun 15, 2022
Bcc2telegraf: An integration that sends ebpf-based bcc histogram metrics to telegraf daemon

bcc2telegraf bcc2telegraf is an integration that sends ebpf-based bcc histogram

Peter Bobrov 2 Feb 17, 2022
A simple python tool for explore your object detection dataset

A simple tool for explore your object detection dataset. The goal of this library is to provide simple and intuitive visualizations from your dataset and automatically find the best parameters for ge

GRADIANT - Centro Tecnolóxico de Telecomunicacións de Galicia 142 Dec 25, 2022
trade bot connected to binance API/ websocket.,, include dashboard in plotly dash to visualize trades and balances

Crypto trade bot 1. What it is Trading bot connected to Binance API. This project made for fun. So ... Do not use to trade live before you have backte

G 3 Oct 07, 2022
Tools for writing, submitting, debugging, and monitoring Storm topologies in pure Python

Petrel Tools for writing, submitting, debugging, and monitoring Storm topologies in pure Python. NOTE: The base Storm package provides storm.py, which

AirSage 247 Dec 18, 2021
paintable GitHub contribute table

githeart paintable github contribute table how to use: Functions key color select 1,2,3,4,5 clear c drawing mode mode on turn off e print paint matrix

Bahadır Araz 27 Nov 24, 2022
Time series visualizer is a flexible extension that provides filling world map by country from real data.

Time-series-visualizer Time series visualizer is a flexible extension that provides filling world map by country from csv or json file. You can know d

Long Ng 3 Jul 09, 2021
Generate graphs with NetworkX, natively visualize with D3.js and pywebview

webview_d3 This is some PoC code to render graphs created with NetworkX natively using D3.js and pywebview. The main benifit of this approac

byt3bl33d3r 68 Aug 18, 2022
A python script editor for napari based on PyQode.

napari-script-editor A python script editor for napari based on PyQode. This napari plugin was generated with Cookiecutter using with @napari's cookie

Robert Haase 9 Sep 20, 2022
An open-source tool for visual and modular block programing in python

PyFlow PyFlow is an open-source tool for modular visual programing in python ! Although for now the tool is in Beta and features are coming in bit by

1.1k Jan 06, 2023
web application for flight log analysis & review

Flight Review This is a web application for flight log analysis. It allows users to upload ULog flight logs, and analyze them through the browser. It

PX4 Drone Autopilot 145 Dec 20, 2022
This is a Web scraping project using BeautifulSoup and Python to scrape basic information of all the Test matches played till Jan 2022.

Scraping-test-matches-data This is a Web scraping project using BeautifulSoup and Python to scrape basic information of all the Test matches played ti

Souradeep Banerjee 4 Oct 10, 2022