POT
POT copied to clipboard
Update plot.py
Added Arrow Annotation Feature to plot2D_samples_mat
Function
Changes:
-
New Parameter
draw_arrows
: Introduced an optional boolean parameterdraw_arrows
to theplot2D_samples_mat
function. When set toTrue
, 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. -
Arrow Placement: The arrows are strategically placed at the midpoint of the lines for clear visualization.
-
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.
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.