Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Plot ellipse with arrow showing rotation #25477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
photoniker opened this issue Mar 16, 2023 · 3 comments · Fixed by #25779
Closed

Plot ellipse with arrow showing rotation #25477

photoniker opened this issue Mar 16, 2023 · 3 comments · Fixed by #25779
Milestone

Comments

@photoniker
Copy link
Contributor

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

@jklymak
Copy link
Member

jklymak commented Mar 16, 2023

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.

@tacaswell
Copy link
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).

@photoniker
Copy link
Contributor Author

photoniker commented Mar 16, 2023

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()

@tacaswell tacaswell added this to the future releases milestone Mar 16, 2023
photoniker pushed a commit to photoniker/matplotlib that referenced this issue Apr 27, 2023
ksunden added a commit that referenced this issue Jun 12, 2023
@QuLogic QuLogic modified the milestones: future releases, v3.8.0 Jun 12, 2023
melissawm pushed a commit to melissawm/matplotlib that referenced this issue Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants