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

Overview

pydrawer πŸ“

licence

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

✏️ Installation

Install pydrawer package with pip:

$ pip install pydrawer

or clone the repository:

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

✏️ Usage

πŸ“Œ Drawing curves

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

from pydrawer import GraphingCalculator

graphing_calculator = GraphingCalculator()

pydrawer 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

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

from pydrawer 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.1

    v1.1.1

    • Updated plotter:
      • Created 'curvipy.ScreenConfiguration(window_title, background_color, window_width, window_height)'.
        • Removed 'window_title' and 'background_color' attributes from 'curvipy.Plotter' as they are now defined at 'curvipy.ScreenConfiguration'.
      • Updated 'curvipy.AxesConfiguration' attributes:
        • Added 'show_axes_direction'
        • Added 'x_ticks_distance' and 'y_ticks_distance'
          • Removed 'x_axis_scale' and 'y_axis_scale'
        • Renamed 'x_axis_ticks' and 'y_axis_ticks' to 'x_ticks' and 'y_ticks'
        • Renamed 'x_axis_tick_decimals' and 'y_axis_tick_decimals' to 'x_ticks_decimals' and 'y_ticks_decimals'
        • Renamed 'x_axis_tick_number_align' and 'y_axis_tick_number_align' to 'x_ticks_align' and 'y_ticks_align'
        • Renamed 'tick_number_color' to 'ticks_color'
        • Renamed 'tick_number_font' to 'ticks_font'
      • Updated 'curvipy.PlottingConfiguration' attributes:
        • Removed 'PlottingConfiguration.show_vector_values'
        • Removed 'PlottingConfiguration.vector_values_line_color'
        • Removed 'PlottingConfiguration.vector_values_line_width'
    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
  • 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
  • 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.1)
  • 1.1.1(Dec 31, 2022)

    • Updated plotter:
      • Created 'curvipy.ScreenConfiguration(window_title, background_color, window_width, window_height)'.
        • Removed 'window_title' and 'background_color' attributes from 'curvipy.Plotter' as they are now defined at 'curvipy.ScreenConfiguration'.
      • Updated 'curvipy.AxesConfiguration' attributes:
        • Added 'show_axes_direction'
        • Added 'x_ticks_distance' and 'y_ticks_distance'
          • Removed 'x_axis_scale' and 'y_axis_scale'
        • Renamed 'x_axis_ticks' and 'y_axis_ticks' to 'x_ticks' and 'y_ticks'
        • Renamed 'x_axis_tick_decimals' and 'y_axis_tick_decimals' to 'x_ticks_decimals' and 'y_ticks_decimals'
        • Renamed 'x_axis_tick_number_align' and 'y_axis_tick_number_align' to 'x_ticks_align' and 'y_ticks_align'
        • Renamed 'tick_number_color' to 'ticks_color'
        • Renamed 'tick_number_font' to 'ticks_font'
      • Updated 'curvipy.PlottingConfiguration' attributes:
        • Removed 'PlottingConfiguration.show_vector_values'
        • Removed 'PlottingConfiguration.vector_values_line_color'
        • Removed 'PlottingConfiguration.vector_values_line_width'
    Source code(tar.gz)
    Source code(zip)
  • 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
Simple implementation of Self Organizing Maps (SOMs) with rectangular and hexagonal grid topologies

py-self-organizing-map Simple implementation of Self Organizing Maps (SOMs) with rectangular and hexagonal grid topologies. A SOM is a simple unsuperv

Jonas Grebe 1 Feb 10, 2022
Backend app for visualizing CANedge log files in Grafana (directly from local disk or S3)

CANedge Grafana Backend - Visualize CAN/LIN Data in Dashboards This project enables easy dashboard visualization of log files from the CANedge CAN/LIN

13 Dec 15, 2022
eoplatform is a Python package that aims to simplify Remote Sensing Earth Observation by providing actionable information on a wide swath of RS platforms and provide a simple API for downloading and visualizing RS imagery

An Earth Observation Platform Earth Observation made easy. Report Bug | Request Feature About eoplatform is a Python package that aims to simplify Rem

Matthew Tralka 4 Aug 11, 2022
A simple project on Data Visualization for CSCI-40 course.

Simple-Data-Visualization A simple project on Data Visualization for CSCI-40 course - the instructions can be found here SAT results in New York in 20

Hugo Matousek 8 Oct 27, 2021
A simple agent-based model used to teach the basics of OOP in my lectures

Pydemic A simple agent-based model of a pandemic. This is used to teach basic principles of object-oriented programming to master students. It is not

Fabien Maussion 2 Jun 08, 2022
A way of looking at COVID-19 data that I haven't seen before.

Visualizing Omicron: COVID-19 Deaths vs. Cases Click here for other countries. Data is from Our World in Data/Johns Hopkins University. About this pro

1 Jan 10, 2022
Colormaps for astronomers

cmastro: colormaps for astronomers πŸ”­ This package contains custom colormaps that have been used in various astronomical applications, similar to cmoc

Adrian Price-Whelan 12 Oct 11, 2022
Main repository for Vispy

VisPy: interactive scientific visualization in Python Main website: http://vispy.org VisPy is a high-performance interactive 2D/3D data visualization

vispy 3k Jan 03, 2023
Minimal Ethereum fee data viewer for the terminal, contained in a single python script.

Minimal Ethereum fee data viewer for the terminal, contained in a single python script. Connects to your node and displays some metrics in real-time.

48 Dec 05, 2022
πŸ§‡ Make Waffle Charts in Python.

PyWaffle PyWaffle is an open source, MIT-licensed Python package for plotting waffle charts. It provides a Figure constructor class Waffle, which coul

Guangyang Li 528 Jan 02, 2023
Custom Plotly Dash components based on Mantine React Components library

Dash Mantine Components Dash Mantine Components is a Dash component library based on Mantine React Components Library. It makes it easier to create go

Snehil Vijay 239 Jan 08, 2023
Some examples with MatPlotLib library in Python

MatPlotLib Example Some examples with MatPlotLib library in Python Point: Run files only in project's directory About me Full name: Matin Ardestani Ag

Matin Ardestani 4 Mar 29, 2022
Friday Night Funkin - converts a chart from 4/4 time to 6/8 time, or from regular to swing tempo.

Chart to swing converter As seen in https://twitter.com/i_winxd/status/1462220493558366214 A program written in python that converts a chart from 4/4

5 Dec 23, 2022
Generating interfaces(CLI, Qt GUI, Dash web app) from a Python function.

oneFace is a Python library for automatically generating multiple interfaces(CLI, GUI, WebGUI) from a callable Python object. oneFace is an easy way t

NaNg 31 Oct 21, 2022
Streamlit-template - A streamlit app template based on streamlit-option-menu

streamlit-template A streamlit app template for geospatial applications based on

Qiusheng Wu 41 Dec 10, 2022
A programming language built on top of Python to easily allow Swahili speakers to get started with programming without ever knowing English

pyswahili A programming language built over Python to easily allow swahili speakers to get started with programming without ever knowing english pyswa

Jordan Kalebu 72 Dec 15, 2022
Data parsing and validation using Python type hints

pydantic Data validation and settings management using Python type hinting. Fast and extensible, pydantic plays nicely with your linters/IDE/brain. De

Samuel Colvin 12.1k Jan 06, 2023
Plotting data from the landroid and a raspberry pi zero to a influx-db

landroid-pi-influx Plotting data from the landroid and a raspberry pi zero to a influx-db Dependancies Hardware: Landroid WR130E Raspberry Pi Zero Wif

2 Oct 22, 2021
A small timeseries transformation API built on Flask and Pandas

#Mcflyin ###A timeseries transformation API built on Pandas and Flask This is a small demo of an API to do timeseries transformations built on Flask a

Rob Story 84 Mar 25, 2022
Design your own matplotlib stylefile interactively

Tired of playing with font sizes and other matplotlib parameters every time you start a new project or write a new plotting function? Want all you plots have the same style? Use matplotlib configurat

yobi byte 207 Dec 08, 2022