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?

  • $\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 Jul 1 '16 at 11:46
  • 1
    $\begingroup$ Have a look at MeshFunctions. $\endgroup$ – J. M.'s ennui Jul 1 '16 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. Jul 1 '16 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 Jul 1 '16 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 Jul 1 '16 at 13:01

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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