0
$\begingroup$

Forgive me if this is answered elsewhere; I was unable to find this specific issue.

For ListStreamDensityPlot, there are three options for PlotRange, which I understand to be the 'x' range, the 'y' range, and the intensity range for the scalar field. I have data of the following form:

data = {{{x1,y1},{{v1x,v1y},v1}},{{x2,y2},{{v2x,v2y},v2}...}

I have two sets of such data. For visualization purposes, I'm using Clip on the velocity norms such that they can only vary between, say, 0 and .15. In something like ReliefPlot, changing this PlotRange changes the color scaling, e.g. a range of {0,.1} would look more varied than if I let the range vary from 0 to .5:

rr200 = RandomReal[{0, .1}, {200, 200}];

ReliefPlot[rr200, ColorFunction -> "DarkRainbow", ImageSize -> 300, 
Frame -> False, PlotRange -> #] & /@ {{0, .5}, {0, .1}} // Row

comparative relief plots

However, I'm not able to replicate this behavior in ListStreamDensityPlot. Here's a kind of bad example that I'm sure could be constructed better:

Create a list of positions to which {{vx,vy},v} values will be joined:

pos100 = Flatten[Table[{i, j}, {i, 100}, {j, 100}], 1];

Create a list of said velocities:

rv100 = Flatten[Map[{#, Norm@#} &, RandomReal[{0, .1}, {100, 100, 2}], {2}], 1];

Join the two lists together:

testDat100 = MapThread[List, {pos100, rv100}];

This should result in a list such that, say, the first element looks like

In[1]:= testDat100[[1]]
Out[1]:= {{1, 1}, {{0.0692235, 0.0907269}, 0.11412}}

which is the form we want. Now, because the maximum x and y velocities were capped at .1, the maximum norm should be ~.14. However, when changing the PlotRange, it doesn't seem to have any effect on the coloring:

ListStreamDensityPlot[testDat100, Frame -> False, 
ColorFunction -> "DarkRainbow", PlotLegends -> Automatic, 
StreamStyle -> White, ImageSize -> 250, 
PlotRange -> {Automatic, 
Automatic, #}] & /@ {{0, .03}, {0, .14}, {0, .5}, {0, 1}} // Row

enter image description here

And now that I do this, I'm seeing something I didn't see in my real data—I have no idea whatsoever why the Automatic BarLegend is going down to -40; I have no sense of where in the data that could even come from. Aside from that, the actual stream plots look identical, and I don't understand why that is.

I suspect that I'm not understanding what quantities are actually represented by the colors here, but I don't see why it would be anything but the scalar field. What's my issue, here? (I'm running v11.3.0.0 on macOS 10.14.)

$\endgroup$
1
$\begingroup$

Firstly, you are using PlotRange incorrectly. Secondly, PlotLegends bar displays the interpolation function, which is used to smooth data. When the data set is small, the bar roughly displays the data itself, and when there are many random data, the interpolation function oscillates not in proportion to the amplitude of the data. All this can be seen on the model, which is given below.

pos[K_] := Flatten[Table[{i, j}, {i, 1, K, 1}, {j, 1, K, 1}], 1];
rv[K_] := 
  Flatten[Map[{#, Norm@#} &, RandomReal[{0, .1}, {K, K, 2}], {2}], 1];
testDat[K_] := MapThread[List, {pos[K], rv[K]}];
g[K_] := ListStreamDensityPlot[testDat[K], 
     ColorFunction -> "DarkRainbow", PlotLegends -> Automatic, 
     StreamStyle -> White, ImageSize -> 250, 
     PlotRange -> {Full, #}] & /@ {{1, K - 5}, {5, K}} // Row

fig1

$\endgroup$
  • $\begingroup$ >Secondly, PlotLegends bar displays the interpolation function, which is used to smooth data. [...] Oh, that makes perfect sense! I didn't think about the error that could be introduced in the test data; that wasn't a problem for my actual data, at least. >Firstly, you are using PlotRange incorrectly. I see! I had incorrectly assumed that it would function like DensityPlot does—thanks for the correction. $\endgroup$ – Ben Kalziqi Sep 7 '18 at 4:55
  • 1
    $\begingroup$ @ Ben Kalziqi Thank you for the quick response. $\endgroup$ – Alex Trounev Sep 7 '18 at 4:58
  • $\begingroup$ On second thought, I don't understand the PlotRange here. I'm not trying to change which physical points I'm looking at (e.g. between 1 and 5 or 5 and 10 in the g[10] example), but instead, which values of the scalar field correspond to which colors in the ColorScheme/BarLegend. $\endgroup$ – Ben Kalziqi Sep 7 '18 at 5:14
  • $\begingroup$ It seems as if providing your list as the second argument of PlotRange just changes the 'y' extent of the plot, and the change in the coloring of the scalar field is a secondary effect. What I'd like is to say, "blue is 0, red is .15—color the interpolation according to those rules". Maybe I'm misunderstanding how this ought to work, though. $\endgroup$ – Ben Kalziqi Sep 7 '18 at 5:14
  • 1
    $\begingroup$ PlotRange in ListStreamDensityPlot acts on the coordinates, on the limits of their variation, but not on the amplitude of the scalar function. $\endgroup$ – Alex Trounev Sep 7 '18 at 5:39

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.