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
Matplotlib JOTA style for making figures

Matplotlib JOTA style for making figures This repo has Matplotlib JOTA style to format plots and figures for publications and presentation.

JOTA JORNALISMO 2 May 05, 2022
HW 2: Visualizing interesting datasets

HW 2: Visualizing interesting datasets Check out the project instructions here! Mean Earnings per Hour for Males and Females My first graph uses data

7 Oct 27, 2021
Lightweight data validation and adaptation Python library.

Valideer Lightweight data validation and adaptation library for Python. At a Glance: Supports both validation (check if a value is valid) and adaptati

Podio 258 Nov 22, 2022
Simple and lightweight Spotify Overlay written in Python.

Simple Spotify Overlay This is a simple yet powerful Spotify Overlay. About I have been looking for something like this ever since I got Spotify. I th

27 Sep 03, 2022
Draw interactive NetworkX graphs with Altair

nx_altair Draw NetworkX graphs with Altair nx_altair offers a similar draw API to NetworkX but returns Altair Charts instead. If you'd like to contrib

Zachary Sailer 206 Dec 12, 2022
A set of three functions, useful in geographical calculations of different sorts

GreatCircle A set of three functions, useful in geographical calculations of different sorts. Available for PHP, Python, Javascript and Ruby. Live dem

72 Sep 30, 2022
Jupyter Notebook extension leveraging pandas DataFrames by integrating DataTables and ChartJS.

Jupyter DataTables Jupyter Notebook extension to leverage pandas DataFrames by integrating DataTables JS. About Data scientists and in fact many devel

Marek Čermák 142 Dec 28, 2022
✅ Today I Learn

Today I Learn EDA numpy_100ex numpy_0~10 airline_satisfaction_prediction BERT_naver_movie_classification NLP_prepare NLP_Tweet_Emotion_Recognition tex

Yeonghoo_Ahn 3 Dec 15, 2022
Designed a greedy algorithm based on Markov sequential decision-making process in MATLAB/Python to optimize using Gurobi solver

Designed a greedy algorithm based on Markov sequential decision-making process in MATLAB/Python to optimize using Gurobi solver, the wheel size, gear shifting sequence by modeling drivetrain constrai

Sabbella Prasanna 1 Jan 11, 2022
An intuitive library to add plotting functionality to scikit-learn objects.

Welcome to Scikit-plot Single line functions for detailed visualizations The quickest and easiest way to go from analysis... ...to this. Scikit-plot i

Reiichiro Nakano 2.3k Dec 31, 2022
Pebble is a stat's visualization tool, this will provide a skeleton to develop a monitoring tool.

Pebble is a stat's visualization tool, this will provide a skeleton to develop a monitoring tool.

Aravind Kumar G 2 Nov 17, 2021
Simple CLI python app to show a stocks graph performance. Made with Matplotlib and Tiingo.

stock-graph-python Simple CLI python app to show a stocks graph performance. Made with Matplotlib and Tiingo. Tiingo API Key You will need to add your

Toby 3 May 14, 2022
Open-questions - Open questions for Bellingcat technical contributors

Open questions for Bellingcat technical contributors These are difficult, long-term projects that would contribute to open source investigations at Be

Bellingcat 234 Dec 31, 2022
Visualize the bitcoin blockchain from your local node

Project Overview A new feature in Bitcoin Core 0.20 allows users to dump the state of the blockchain (the UTXO set) using the command dumptxoutset. I'

18 Sep 11, 2022
Keir&'s Visualizing Data on Life Expectancy

Keir's Visualizing Data on Life Expectancy Below is information on life expectancy in the United States from 1900-2017. You will also find information

9 Jun 06, 2022
These data visualizations were created as homework for my CS40 class. I hope you enjoy!

Data Visualizations These data visualizations were created as homework for my CS40 class. I hope you enjoy! Nobel Laureates by their Country of Birth

9 Sep 02, 2022
Quickly and accurately render even the largest data.

Turn even the largest data into images, accurately Build Status Coverage Latest dev release Latest release Docs Support What is it? Datashader is a da

HoloViz 2.9k Dec 28, 2022
By default, networkx has problems with drawing self-loops in graphs.

By default, networkx has problems with drawing self-loops in graphs. It makes it hard to draw a graph with self-loops or to make a nicely looking chord diagram. This repository provides some code to

Vladimir Shitov 5 Jan 06, 2022
This is a sorting visualizer made with Tkinter.

Sorting-Visualizer This is a sorting visualizer made with Tkinter. Make sure you've installed tkinter in your system to use this visualizer pip instal

Vishal Choubey 7 Jul 06, 2022
Write python locally, execute SQL in your data warehouse

RasgoQL Write python locally, execute SQL in your data warehouse ≪ Read the Docs · Join Our Slack » RasgoQL is a Python package that enables you to ea

Rasgo 265 Nov 21, 2022