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

Easier Mathemetica-like VectorPlots #469

Open
MithicSpirit opened this issue Feb 10, 2024 · 0 comments
Open

Easier Mathemetica-like VectorPlots #469

MithicSpirit opened this issue Feb 10, 2024 · 0 comments

Comments

@MithicSpirit
Copy link

While quiver plots can be made to emulate VectorPlots, it is quite annoying. In particular, the main issue is representing vector magnitude with a color rather than as the length of the arrow. Currently, it is possible to fix this by dividing each coordinate by the magnitude of the vector, setting the point meta to the magnitude, and telling it to color the arrows. If the scales of the axes are not the same, this must also be adjusted for. Also, it may be necessary to mess around with the arrow scale to prevent overlap between the arrows. This usecase seems to be entirely undocumented in the 1.18.1 manual, which further adds to its difficulty.

It would be much more convenient if there was an option that automatically normalized all the vectors. This should account for differing scales, and, if possible, the distance between neighboring arrows (I've found that around 80% of the distance between an arrow and its nearest neighbor looks best). Another option (or maybe the same) that set the point meta to the (pre-normalized) magnitude would also be helpful.

As an example of the problem this would fix, here is a before an after with some sample option names:

% before
\addplot3 [
  samples = 12,
  point meta = {sqrt((0.5*y)^2 + (-6*x)^2)},
  quiver = {
    u = {0.5*y / sqrt((0.5*y)^2 + (-6*x)^2)},
    v = {-6*x / sqrt((0.5*y)^2 + (-6*x)^2)},
    colored,
    scale arrows = 0.03,
    },
  -latex,
] {0};

% after
\addplot3 [
  samples = 12,
  quiver = {
    u = {0.5*y},
    v = {-6*x},
    normalize,
    point meta magnitude,
    colored,
    },
  -latex,
] {0};

This, of course, does not show how long I spent trying to figure out how to do this, and then messing around with scale arrows, and then doing so again when I decided to change my domains and samples. While there is a trick with setting the z variable to the magnitude of the vector and then using that variable in point meta, u, and v, this does not work in all situations.

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

No branches or pull requests

1 participant