1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python Plotting Using Class

Discussão em 'Python' iniciado por Stack, Fevereiro 1, 2025.

  1. Stack

    Stack Membro Participativo

    I have to define a class point(x,y) that represents a point in a Euclidean plane, which I completed with:

    class point():
    def __init__(P,x,y):
    P.x=x
    P.y=y


    Now I must extend this class by creating methods that will:

    1. Return a point A that is a vertical reflection of P across the horizontal line at y using A=P.verticalReflect(y).
    2. Return a point B that translates the point P a distance of x in the x-direction and a distance of y in the y-direction using B=P.translate(x,y).
    3. Display a point using pyplot using P.display(options). I should be able to let the user print a label, set the font size and offset from the point.

    An example of code that will initiate the class created would be:

    P=point(2,3)
    P.display(label="P",labeloffset=0.2)

    A=P.verticalReflect(y=3.5)
    A.display(c="green",label="A",labeloffset=0.1)
    plt.axhline(y=3.5,c="k",ls="--")


    I'm having trouble figuring out where to start to define these new methods in the class.

    Continue reading...

Compartilhe esta Página