0
$\begingroup$

I dont know why so many plot functions lack the option to display contour lines (judging by the search result for [plot function] contour lines) but ListVectorPlot is among them.

If I have an array t of {vx,vy} coordinates, do you know a way to plot it with overimposed the contour lines?

$\endgroup$
9
  • $\begingroup$ As in ListVectorDensityPlot[]? It doesn't have lines, but really lines just clutter up such a graph. You might have to superimpose two graphs if you really want the lines themselves. $\endgroup$
    – Feyre
    Commented Jul 1, 2016 at 11:46
  • 1
    $\begingroup$ Have a look at MeshFunctions. $\endgroup$ Commented Jul 1, 2016 at 12:09
  • $\begingroup$ Two options come to mind, first the StreamPoints option VectorPlot and ListVectorPlot. Second, you could just use Show to combine different types of 2D plots $\endgroup$
    – Jason B.
    Commented Jul 1, 2016 at 12:46
  • $\begingroup$ @J.M.: I never used it so probably I made some mistake. I tried this syntax: ListVectorPlot[tt, VectorPoints -> 40, Mesh -> 20, MeshFunctions -> {#1 &}] and though I get no error, I see no meshes... $\endgroup$
    – alessandro
    Commented Jul 1, 2016 at 13:00
  • $\begingroup$ @JasonB: I thought it was a great idea using StreamPoints, until I realized that the streamlines are exactly perpendicular to the direction I need, that is the contour line! $\endgroup$
    – alessandro
    Commented Jul 1, 2016 at 13:01

1 Answer 1

1
$\begingroup$

Here is a ListVectorPlot superimposed on top of ListContourPlot(s) of the vx, vy, and magnitudes

data = Import["~/Downloads/tt.mat"];
vectorplot = ListVectorPlot[Transpose@data, VectorStyle -> Red];
Show[ListContourPlot[Map[#, data, {2}]], vectorplot, ImageSize -> 400,
    PlotRange -> All] & /@ {First, Last, Norm[#]^2 &}

Mathematica graphics

Or you can use MeshFunctions to get the contour lines out of ListVectorDensityPlot

ListVectorDensityPlot[Map[#, Transpose@data, {2}], Mesh -> 10, 
   MaxRecursion -> 3, ImageSize -> 400, 
   VectorStyle -> Red] & /@ {{#, First@#} &, {#, Last@#} &, {#, 
    Norm@#} &}

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ thanks! I understand better how to do it now... $\endgroup$
    – alessandro
    Commented Jul 1, 2016 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.