Skip to content
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

Update plot.py #514

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Update plot.py #514

wants to merge 3 commits into from

Conversation

kiasar
Copy link

@kiasar kiasar commented Aug 25, 2023

Added Arrow Annotation Feature to plot2D_samples_mat Function

Changes:

  1. New Parameter draw_arrows: Introduced an optional boolean parameter draw_arrows to the plot2D_samples_mat function. When set to True, this parameter allows users to plot arrows in the middle of the lines connecting source and target samples. This helps to visually identify the direction from source to target.

  2. Arrow Placement: The arrows are strategically placed at the midpoint of the lines for clear visualization.

  3. Arrow Properties: The color and alpha (transparency) of the arrows match the lines they are associated with, ensuring visual consistency.

As a visual example, this update allows the user to choose between these two types.
image
image

Motivation:

The addition of the arrow annotation feature enhances the visual representation of the connections between source and target samples. Especially in cases where directionality matters, these arrows provide a clearer understanding of the flow from source to target.

Code:

The main code changes involve:

  • Calculating the midpoint of the line segments.
  • Using the plt.annotate method to draw an arrow at the calculated midpoint.

Example Usage:

plot2D_samples_mat(xs, xt, G, draw_arrows=True)

Types of changes

Motivation and context / Related issue

How has this been tested (if it applies)

PR checklist

  • I have read the CONTRIBUTING document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • All tests passed, and additional code has been covered with new tests.
  • I have added the PR and Issue fix to the RELEASES.md file.

kiasar and others added 3 commits August 26, 2023 00:13
## Added Arrow Annotation Feature to `plot2D_samples_mat` Function

### Changes:

1. **New Parameter `draw_arrows`**: Introduced an optional boolean parameter `draw_arrows` to the `plot2D_samples_mat` function. When set to `True`, this parameter allows users to plot arrows in the middle of the lines connecting source and target samples. This helps to visually identify the direction from source to target.

2. **Arrow Placement**: The arrows are strategically placed at the midpoint of the lines for clear visualization.

3. **Arrow Properties**: The color and alpha (transparency) of the arrows match the lines they are associated with, ensuring visual consistency.

### Motivation:

The addition of the arrow annotation feature enhances the visual representation of the connections between source and target samples. Especially in cases where directionality matters, these arrows provide a clearer understanding of the flow from source to target.

### Code:

The main code changes involve:
- Calculating the midpoint of the line segments.
- Using the `plt.annotate` method to draw an arrow at the calculated midpoint.

### Example Usage:

```python
plot2D_samples_mat(xs, xt, G, draw_arrows=True)
```
@rflamary
Copy link
Collaborator

Hello @kiasar thanks for the contribution, the test are failing at the moment, I will do a code reviews as soon as possible when they as they pas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants