-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
Milestone
Description
Problem
- I'm attempting to make a vector map using the quiver tool (to overlay vectors on a background plot), but implementation of the data I'm using has not been so intuitive.
- I have a 2D array with values indicating vector angle (additionally, another one indicating strengths). quiver requires converting the 2D arrays into a list of lists and the input parameters are not very intuitive (at least to me).
- Additionally, scaling the coordinate system is not a feature I've seen.
Minimum working example of how I'm able to achieve a "vector map"
import matplotlib.pyplot as plt
import numpy as np
ones=np.ones((16,16)) # 2D numpy array containing coordinates
angles=ones*45 # 2D numpy array containing coordinate angles
olist=ones.tolist()
alist=angles.tolist()
ax=plt.subplot()
ax.quiver(olist,olist,angles=angles,headwidth=0,headlength=0,headaxislength=0,units='xy',width=0.1)
plt.show()
Proposed solution
I would suggest a new plotting tool with the ability for direct input of 2D arrays for vector direction and magnitude with coordinate system transformations included as an option. A user with large plots may not want to include every single vector component, so an additional parameter could indicate the density of the plot where the plot only shows every fifth pixel in a row. (similar to a slice, though, this may be tricky with coordinate transforms). Additional options could include line thickness, color, arrowheads, etc.
Examples:
ones=np.ones((16,16))
angles=ones*45
transform=ax.get_transform(WCS) # some coordinate system transformation object
ax.vectors(orientation=angles) # a plot of unit magnitude vectors with specificed orientations
ax.vectors(orientation=angles,density=slice(None,None,5)) # same as above with a reduced density
ax.vectors(magnitude=ones,orientation=angles) # input 2D arrays with magnitude and orientation
ax.vectors(magnitude=ones,orientation=angles,transform=transform) # transform coordinates similar to ax.contour
plt.show()
I'm not so well versed in the matplotlib coding structure but I would be happy to help to learn about how it works.