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

colormap support for 3d quiver #3382

Closed
twmr opened this issue Aug 18, 2014 · 10 comments
Closed

colormap support for 3d quiver #3382

twmr opened this issue Aug 18, 2014 · 10 comments
Assignees
Labels
keep Items to be ignored by the “Stale” Github Action New feature topic: mplot3d

Comments

@twmr
Copy link
Contributor

twmr commented Aug 18, 2014

It would be nice to have support for a colormap kwarg (like the C kwarg in the 2d implementation of quiver http://matplotlib.org/api/axes_api.html?highlight=quiver#matplotlib.axes.Axes.quiver) in the 3d version of quiver.

@tacaswell
Copy link
Member

cc @WeatherGod

@perimosocordiae
Copy link
Contributor

It's currently possible to do this with a little bit of colormap trickery. Assuming you have an array of scalar color values between 0 and 1 named C:

cmap = plt.get_cmap()
ax.quiver(x,y,z,u,v,w,color=cmap(C))

I agree that support for this would be nice to have directly in the quiver function itself.

@tacaswell
Copy link
Member

This actually goes back to a limitation of the LineCollection class...

@tacaswell tacaswell self-assigned this Oct 28, 2014
@perimosocordiae
Copy link
Contributor

I also just realized that you'd need to do np.repeat(C, 3) first, because quiver creates three lines for each arrow in the plot.

@delooper
Copy link

I'm reading in the linecollection API for matplotlib 1.5.1 and it looks like you should be able to assign colors arrow-by-arrow but I haven't determined what format the library wants the call to be in. The library makes it sound like it needs a nxmxkx3 or a nxmxkx4 array depending on if you are using RGB or RGBA colors. But I'm not having any luck with it.

@WeatherGod
Copy link
Member

Most likely, the problem is that the colors might be getting re-assigned by
other parts of mplot3d. Color-handling has been extremely tricky in mplot3d.

On Thu, Mar 17, 2016 at 5:02 PM, Ryan Budney notifications@github.com
wrote:

I'm reading in the linecollection API for matplotlib 1.5.1 and it looks
like you should be able to assign colors arrow-by-arrow but I haven't
determined what format the library wants the call to be in. The library
makes it sound like it needs a nxmxkx3 or a nxmxkx4 array depending on if
you are using RGB or RGBA colors. But I'm not having any luck with it.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#3382 (comment)

@delooper
Copy link

Do you know if one can change the length or width of a 3d quiver plot, element-by-element? I haven't had luck with that, either.

@sytrus-in-github
Copy link

sytrus-in-github commented Apr 14, 2017

@delooper I have just opend another issue on specifying colors for each arrow in 3D quiver plot (since this one is more about colormap) in which I have given a work around for my case:

  • reshape your array of shape (n,m,k,3) to (n*m*k, 3) (4 for RGBA I suppose)
  • filter out color values corresponding to vectors of length 0 because they won't be drawn ...
  • specify colors = array + repeatEachElement(array, 2) since first all "-" part of "->" will be drawn then the ">" part will be drawn

Hope this helps.

@story645 story645 modified the milestones: unassigned, needs sorting Oct 6, 2022
@github-actions
Copy link

github-actions bot commented Oct 9, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Oct 9, 2023
@github-actions github-actions bot added the status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. label Nov 8, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2023
@scottshambaugh scottshambaugh added keep Items to be ignored by the “Stale” Github Action and removed status: inactive Marked by the “Stale” Github Action status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. labels May 16, 2024
@scottshambaugh
Copy link
Contributor

This is covered by the colors kwarg that is passed to Line3DCollection, and was fixed in #27754. Feel free to reopen if I'm wrong there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep Items to be ignored by the “Stale” Github Action New feature topic: mplot3d
Projects
None yet
Development

No branches or pull requests

8 participants