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
SummVis is an interactive visualization tool for text summarization.

SummVis is an interactive visualization tool for analyzing abstractive summarization model outputs and datasets.

Robustness Gym 246 Dec 08, 2022
The visual framework is designed on the idea of module and implemented by mixin method

Visual Framework The visual framework is designed on the idea of module and implemented by mixin method. Its biggest feature is the mixins module whic

LEFTeyes 9 Sep 19, 2022
Gaphas is the diagramming widget library for Python.

Gaphas Gaphas is the diagramming widget library for Python. Gaphas is a library that provides the user interface component (widget) for drawing diagra

Gaphor 144 Dec 14, 2022
Open-source demos hosted on Dash Gallery

Dash Sample Apps This repository hosts the code for over 100 open-source Dash apps written in Python or R. They can serve as a starting point for your

Plotly 2.7k Jan 07, 2023
Visualization of the World Religion Data dataset by Correlates of War Project.

World Religion Data Visualization Visualization of the World Religion Data dataset by Correlates of War Project. Mostly personal project to famirializ

Emile Bangma 1 Oct 15, 2022
Color scales in Python for humans

colorlover Color scales for humans IPython notebook: https://plot.ly/ipython-notebooks/color-scales/ import colorlover as cl from IPython.display impo

Plotly 146 Sep 25, 2022
Generate the report for OCULTest.

Sample report generated in this function Usage example from utils.gen_report import generate_report if __name__ == '__main__': # def generate_rep

Philip Guo 1 Mar 10, 2022
View part of your screen in grayscale or simulated color vision deficiency.

monolens View part of your screen in grayscale or filtered to simulate color vision deficiency. Watch the demo on YouTube. Install with pip install mo

Hans Dembinski 31 Oct 11, 2022
Data visualization using matplotlib

Data visualization using matplotlib project instructions Top 5 Most Common Coffee Origins In this visualization I used data from Ankur Chavda on Kaggl

13 Oct 27, 2021
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
HW_02 Data visualisation task

HW_02 Data visualisation and Matplotlib practice Instructions for HW_02 Idea for data analysis As I was brainstorming ideas and running through databa

9 Dec 13, 2022
nptsne is a numpy compatible python binary package that offers a number of APIs for fast tSNE calculation.

nptsne nptsne is a numpy compatible python binary package that offers a number of APIs for fast tSNE calculation and HSNE modelling. For more detail s

Biomedical Visual Analytics Unit LUMC - TU Delft 29 Jul 05, 2022
Productivity Tools for Plotly + Pandas

Cufflinks This library binds the power of plotly with the flexibility of pandas for easy plotting. This library is available on https://github.com/san

Jorge Santos 2.7k Dec 30, 2022
Regress.me is an easy to use data visualization tool powered by Dash/Plotly.

Regress.me Regress.me is an easy to use data visualization tool powered by Dash/Plotly. Regress.me.-.Google.Chrome.2022-05-10.15-58-59.mp4 Get Started

Amar 14 Aug 14, 2022
Turn a STAC catalog into a dask-based xarray

StackSTAC Turn a list of STAC items into a 4D xarray DataArray (dims: time, band, y, x), including reprojection to a common grid. The array is a lazy

Gabe Joseph 148 Dec 19, 2022
Investment and risk technologies maintained by Fortitudo Technologies.

Fortitudo Technologies Open Source This package allows you to freely explore open-source implementations of some of our fundamental technologies under

Fortitudo Technologies 11 Dec 14, 2022
CPG represent!

CoolPandasGroup CPG represent! Arianna Brandon Enne Luan Tracie Project requirements: use Pandas to clean and format datasets use Jupyter Notebook to

Enne 3 Feb 07, 2022
A toolkit to generate MR sequence diagrams

mrsd: a toolkit to generate MR sequence diagrams mrsd is a Python toolkit to generate MR sequence diagrams, as shown below for the basic FLASH sequenc

Julien Lamy 3 Dec 25, 2021
AB-test-analyzer - Python class to perform AB test analysis

AB-test-analyzer Python class to perform AB test analysis Overview This repo con

13 Jul 16, 2022
A Python wrapper of Neighbor Retrieval Visualizer (NeRV)

PyNeRV A Python wrapper of the dimensionality reduction algorithm Neighbor Retrieval Visualizer (NeRV) Compile Set up the paths in Makefile then make.

2 Aug 29, 2021