0
$\begingroup$

I would like to plot several stream plots as is in ref/StreamPlot (Mathematica 12).

As is reported in the section: Generate a list of stream plots of varying [Lambda]:

I did not change but it does not work as this example.

The problem is, there is field that may represent a bidimensional vector (Electric,Acoustic), this is the code.

a = 1; b = 1;  (* fixed values, constants *)

f1 = (-y  l )/(y^2 + a x^2);

f2 = ( x l )/(b y^2 + x^2);


l = {-1, 0, 1};  (* This can take several values *)

plots = MapIndexed[
  Function[{f1, f2}, 
   StreamPlot[{f1, f2}, {x, -3, 3}, {y, -3, 3}, StreamPoints -> 16, 
    StreamScale -> 0.07, 
    StreamStyle -> ColorData["SolarColors"][0.3 l[[1]]]]], l]

plotSpacing = 5;
stackPlots[plots, plotSpacing, Axes -> True, Boxed -> False, 
 Ticks -> {Automatic, Automatic, 
   MapIndexed[{plotSpacing #2[[1]], Row[{"l = ", #1}]} &, values]}]

It does not work, only the constant value is plotted. the function can not take different values as must be. This function does not evaluate the vector.Thanks!

$\endgroup$

1 Answer 1

1
$\begingroup$

Do you mean this plot?

a = 1; b = 1;(*fixed values,constants*)
f1 = (-y l)/(y^2 + a x^2);
f2 = (x l)/(b y^2 + x^2);
Function[{f1, f2}, 
  StreamPlot[{f1, f2}, {x, -3, 3}, {y, -3, 3}, StreamPoints -> 16, 
   StreamScale -> 0.07, 
   StreamStyle -> ColorData["SolarColors"][0.3 ]]] @@@ 
 Table[{f1, f2}, {l, {-1, 0, 1}}]

Table[StreamPlot[{f1, f2}, {x, -3, 3}, {y, -3, 3}, StreamPoints -> 16,
   StreamScale -> 0.07, 
  StreamStyle -> ColorData["SolarColors"][0.3 ]], {l, {-1, 0, 1}}]

enter image description here

$\endgroup$
1
  • $\begingroup$ @Moo The main problem is MapIndexed not right here since we know that MapIndexed[g[#1, #2] &, {-1, 0, 1}] is {g[-1, {1}], g[0, {2}], g[1, {3}]}. $\endgroup$
    – cvgmt
    Jul 22, 2021 at 14:58

Your Answer

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

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