POT icon indicating copy to clipboard operation
POT copied to clipboard

Update plot.py

Open kiasar opened this issue 10 months ago • 1 comments

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.
  • [x] The documentation is up-to-date with the changes I made (check build artifacts).
  • [x] 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 avatar Aug 25 '23 22:08 kiasar