Skip to content

Plot ellipse with arrow showing rotation #25477

Closed

Description

@photoniker

Problem

I'm trying to plot an ellipse together with an arrow showing a rotation clockwise or counterclockwise as it is shown in that image.

image

That can ben implement by another optional argument?

Proposed solution

No response

Activity

  1. jklymak commented on Mar 16, 2023

    @jklymak
    Member

    I don't think we would add this to a low level patch like ellipse. It's certainly possible to get the effect you want with an annotation arrow and a basic ellipses. If you need help with that discourse.Matplotlib.org is a good place to ask.

  2. tacaswell commented on Mar 16, 2023

    @tacaswell
    Member

    I agree that this is probably too specific to put into the core library, but I would be open to a PR adding that as an example or tutorial (I think there is a way to build up that figure step-by-step that would fit in the divio "tutorial" definition).

  3. photoniker commented on Mar 16, 2023

    @photoniker
    ContributorAuthor

    Here is an example I created.

    import matplotlib.pyplot as plt
    import numpy as np
    
    fig, ax = plt.subplots(1, 1, subplot_kw={"aspect": "equal"})
    
    ax.axvline(c="grey", lw=1)
    ax.axhline(c="grey", lw=1)
    
    xVec = 0.5+0.5j
    yVec = 0.2+0.5j
    
    sampling = 101
    n = np.linspace(0, sampling, sampling)
    
    x = np.real(xVec * np.exp(1j * 2 * np.pi * n / sampling))
    y = np.real(yVec * np.exp(1j * 2 * np.pi * n / sampling))
    ax.plot(x, y)
    
    dx = x[-1] - x[-2]
    dy = y[-1] - y[-2]
    ax.arrow(x=x[-1], y=y[-1], dx=dx, dy=dy, head_width=0.05)
    
    ax.grid()
    ax.set_xlim((-1, 1))
    ax.set_ylim((-1, 1))
    plt.show()
    
  4. added this to the future releases milestone on Mar 16, 2023
  5. added a commit that references this issue on Apr 27, 2023
    eeed6fc
  6. added a commit that references this issue on Jun 12, 2023
    c3a2794
  7. added a commit that references this issue on Jun 15, 2023
    5b65397
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions