Bug in VectorFieldPlot[] with InterpolatingFunction[]?How do I Plot a Divergence?Trying to generate a...

Tikz/Pgf - Surf plot with smooth color transition

Maybe pigeonhole problem?

Calculating the strength of an ionic bond that contains poly-atomic ions

Lubuntu 18.10 File Manager: How to view directory tree structure?

What's the winning box for the King in a Queen against 7th rank Bishop-pawn endgame?

Sensor logger for Raspberry Pi in a stratospheric probe

Given a total recursive function, can you always compute its fixed-point?

How to check if remote-signer is working as expected?

Why did Ylvis use "go" instead of "say" in phrases like "Dog goes 'woof'"?

Why is Shelob considered evil?

Critique vs nitpicking

How do dictionaries source attestation

What does an unprocessed RAW file look like?

How to not let the Identify spell spoil everything?

Is it possible to detect 100% of SQLi with a simple regex?

Why might frozen potatoes require a hechsher?

If angels and devils are the same species, why would their mortal offspring appear physically different?

How unreachable are Jupiter's moons from Mars with the technology developed for going to Mars?

Homeostasis logic/math problem

What are some idioms that means something along the lines of "switching it up every day to not do the same thing over and over"?

How much light is too much?

How can I prevent an oracle who can see into the past from knowing everything that has happened?

Players preemptively rolling, even though their rolls are useless or are checking the wrong skills

How to deal with an underperforming subordinate?



Bug in VectorFieldPlot[] with InterpolatingFunction[]?


How do I Plot a Divergence?Trying to generate a function from InterpolatingFunction with FunctionInterpolationPrevent Plus from threading InterpolatingFunctionInterpolatingFunction with growing DomainTransform an InterpolatingFunctionUsing InterpolatingFunction in equationsBuild an InterpolatingFunction with ElementMeshInterpolationPlot components of vector valued InterpolatingFunctionDealing with InterpolatingFunction in CompileSeveral errors with InterpolatingFunctionInterpolatingFunction gives different result when plot













5












$begingroup$


While looking at How do I Plot a Divergence?, I thought to suggest the following as a solution to the OP's problem (where potdistr is an InterpolatingFunction solution to a PDE returned by NDSolve):



VectorDensityPlot[
Evaluate[Grad[potdistr[x, y], {x, y}]],
{x, -0.01, 0.11}, {y, -0.005, 0.053}]


I surprised that it worked once and then failed on subsequent calls. It seems to be connected to InterpolatingFunction and values being set for x and y. Here is a minimal example:



field = {Interpolation[Range[4]^2/4][y], x};
VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]


Subsequent calls generate a InterpolatingFunction::dmval extrapolation warning message and the vector field is constant.



The problem does not occur if field = {y^2/4, x} is used. It does not occur for VectorPlot, DensityPlot, ContourPlot, or Plot3D.



What's going on? Is it a bug? Is there a way to get it to work?



Additional info:



$Version
(* "11.3.0 for Mac OS X x86 (64-bit) (January 22, 2018)" *)


Filed as [CASE:4228039]










share|improve this question











$endgroup$












  • $begingroup$
    I was fiddling with the same problem, and had odd results when attempting to do a StreamPlot of the gradient of potexpr.
    $endgroup$
    – MikeY
    5 hours ago


















5












$begingroup$


While looking at How do I Plot a Divergence?, I thought to suggest the following as a solution to the OP's problem (where potdistr is an InterpolatingFunction solution to a PDE returned by NDSolve):



VectorDensityPlot[
Evaluate[Grad[potdistr[x, y], {x, y}]],
{x, -0.01, 0.11}, {y, -0.005, 0.053}]


I surprised that it worked once and then failed on subsequent calls. It seems to be connected to InterpolatingFunction and values being set for x and y. Here is a minimal example:



field = {Interpolation[Range[4]^2/4][y], x};
VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]


Subsequent calls generate a InterpolatingFunction::dmval extrapolation warning message and the vector field is constant.



The problem does not occur if field = {y^2/4, x} is used. It does not occur for VectorPlot, DensityPlot, ContourPlot, or Plot3D.



What's going on? Is it a bug? Is there a way to get it to work?



Additional info:



$Version
(* "11.3.0 for Mac OS X x86 (64-bit) (January 22, 2018)" *)


Filed as [CASE:4228039]










share|improve this question











$endgroup$












  • $begingroup$
    I was fiddling with the same problem, and had odd results when attempting to do a StreamPlot of the gradient of potexpr.
    $endgroup$
    – MikeY
    5 hours ago
















5












5








5





$begingroup$


While looking at How do I Plot a Divergence?, I thought to suggest the following as a solution to the OP's problem (where potdistr is an InterpolatingFunction solution to a PDE returned by NDSolve):



VectorDensityPlot[
Evaluate[Grad[potdistr[x, y], {x, y}]],
{x, -0.01, 0.11}, {y, -0.005, 0.053}]


I surprised that it worked once and then failed on subsequent calls. It seems to be connected to InterpolatingFunction and values being set for x and y. Here is a minimal example:



field = {Interpolation[Range[4]^2/4][y], x};
VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]


Subsequent calls generate a InterpolatingFunction::dmval extrapolation warning message and the vector field is constant.



The problem does not occur if field = {y^2/4, x} is used. It does not occur for VectorPlot, DensityPlot, ContourPlot, or Plot3D.



What's going on? Is it a bug? Is there a way to get it to work?



Additional info:



$Version
(* "11.3.0 for Mac OS X x86 (64-bit) (January 22, 2018)" *)


Filed as [CASE:4228039]










share|improve this question











$endgroup$




While looking at How do I Plot a Divergence?, I thought to suggest the following as a solution to the OP's problem (where potdistr is an InterpolatingFunction solution to a PDE returned by NDSolve):



VectorDensityPlot[
Evaluate[Grad[potdistr[x, y], {x, y}]],
{x, -0.01, 0.11}, {y, -0.005, 0.053}]


I surprised that it worked once and then failed on subsequent calls. It seems to be connected to InterpolatingFunction and values being set for x and y. Here is a minimal example:



field = {Interpolation[Range[4]^2/4][y], x};
VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]


Subsequent calls generate a InterpolatingFunction::dmval extrapolation warning message and the vector field is constant.



The problem does not occur if field = {y^2/4, x} is used. It does not occur for VectorPlot, DensityPlot, ContourPlot, or Plot3D.



What's going on? Is it a bug? Is there a way to get it to work?



Additional info:



$Version
(* "11.3.0 for Mac OS X x86 (64-bit) (January 22, 2018)" *)


Filed as [CASE:4228039]







plotting evaluation interpolation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 hours ago







Michael E2

















asked 6 hours ago









Michael E2Michael E2

148k12198475




148k12198475












  • $begingroup$
    I was fiddling with the same problem, and had odd results when attempting to do a StreamPlot of the gradient of potexpr.
    $endgroup$
    – MikeY
    5 hours ago




















  • $begingroup$
    I was fiddling with the same problem, and had odd results when attempting to do a StreamPlot of the gradient of potexpr.
    $endgroup$
    – MikeY
    5 hours ago


















$begingroup$
I was fiddling with the same problem, and had odd results when attempting to do a StreamPlot of the gradient of potexpr.
$endgroup$
– MikeY
5 hours ago






$begingroup$
I was fiddling with the same problem, and had odd results when attempting to do a StreamPlot of the gradient of potexpr.
$endgroup$
– MikeY
5 hours ago












2 Answers
2






active

oldest

votes


















5












$begingroup$

What is happening is that x and y are being set equal to numeric values. (One might notice that the color for x and y changes from blue to black, but my eyes have trouble seeing that for single-letter variables.) For some reason, these values are outside the domain specified in the plot. I think this must be a bug and have reported it to WRI.



Clear[x, y]
{x, y}
field = {Interpolation[Range[4]^2/4][y], x};
VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]
{x, y}


enter image description here



One possible workaround is to clear the variables after plotting with Clear[x, y]. Another is to use Block:



Block[{x, y}, VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]]


Further, it does not seem restricted only to InterpolatingFunction. The following has the same issue, and, further, VectorStyle is ignored:



Clear[x, y, ff]
{x, y}
ff[xx_, yy_] := {yy^2/4, xx};
VectorDensityPlot[ff[x, y], {x, 1, 4}, {y, 1, 4}, VectorStyle -> Red]
{x, y}
(* output is the same as above, same coloring *)


Pre-evaluating ff[x, y] gives the desired plot:



VectorDensityPlot[Evaluate@ff[x, y], {x, 1, 4}, {y, 1, 4}, VectorStyle -> Red]





share|improve this answer









$endgroup$





















    1












    $begingroup$

    This works...once you have potdistr, run this to get a Function



    pdg = Evaluate[Grad[potdistr[#1, #2], {#1, #2}]] &


    You can then run the plot function repeatedly, no problem, and go back and run previous statements (you couldn't when x, y were getting set).



    VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]
    VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]
    VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]


    enter image description here



    You can also run this kludgy version, but it is slow.



    VectorDensityPlot[Evaluate[Grad[potdistr[#1, #2], {#1, #2}]] &[x, y], 
    {x, 0, 0.1}, {y, 0, 0.05}]


    I was interested in the not very useful looking StreamPlot I was getting.



    StreamPlot[pdg[x, y], {x, 0, 0.1}, {y, 0, 0.05}]


    enter image description here



    One thing I found odd is that if you look at the domain for potdistr versus the plot ranges people are using, there should be some extrapolation going on. Shouldn't we get warnings for that?






    share|improve this answer









    $endgroup$













      Your Answer





      StackExchange.ifUsing("editor", function () {
      return StackExchange.using("mathjaxEditing", function () {
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      });
      });
      }, "mathjax-editing");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "387"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192118%2fbug-in-vectorfieldplot-with-interpolatingfunction%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      5












      $begingroup$

      What is happening is that x and y are being set equal to numeric values. (One might notice that the color for x and y changes from blue to black, but my eyes have trouble seeing that for single-letter variables.) For some reason, these values are outside the domain specified in the plot. I think this must be a bug and have reported it to WRI.



      Clear[x, y]
      {x, y}
      field = {Interpolation[Range[4]^2/4][y], x};
      VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]
      {x, y}


      enter image description here



      One possible workaround is to clear the variables after plotting with Clear[x, y]. Another is to use Block:



      Block[{x, y}, VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]]


      Further, it does not seem restricted only to InterpolatingFunction. The following has the same issue, and, further, VectorStyle is ignored:



      Clear[x, y, ff]
      {x, y}
      ff[xx_, yy_] := {yy^2/4, xx};
      VectorDensityPlot[ff[x, y], {x, 1, 4}, {y, 1, 4}, VectorStyle -> Red]
      {x, y}
      (* output is the same as above, same coloring *)


      Pre-evaluating ff[x, y] gives the desired plot:



      VectorDensityPlot[Evaluate@ff[x, y], {x, 1, 4}, {y, 1, 4}, VectorStyle -> Red]





      share|improve this answer









      $endgroup$


















        5












        $begingroup$

        What is happening is that x and y are being set equal to numeric values. (One might notice that the color for x and y changes from blue to black, but my eyes have trouble seeing that for single-letter variables.) For some reason, these values are outside the domain specified in the plot. I think this must be a bug and have reported it to WRI.



        Clear[x, y]
        {x, y}
        field = {Interpolation[Range[4]^2/4][y], x};
        VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]
        {x, y}


        enter image description here



        One possible workaround is to clear the variables after plotting with Clear[x, y]. Another is to use Block:



        Block[{x, y}, VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]]


        Further, it does not seem restricted only to InterpolatingFunction. The following has the same issue, and, further, VectorStyle is ignored:



        Clear[x, y, ff]
        {x, y}
        ff[xx_, yy_] := {yy^2/4, xx};
        VectorDensityPlot[ff[x, y], {x, 1, 4}, {y, 1, 4}, VectorStyle -> Red]
        {x, y}
        (* output is the same as above, same coloring *)


        Pre-evaluating ff[x, y] gives the desired plot:



        VectorDensityPlot[Evaluate@ff[x, y], {x, 1, 4}, {y, 1, 4}, VectorStyle -> Red]





        share|improve this answer









        $endgroup$
















          5












          5








          5





          $begingroup$

          What is happening is that x and y are being set equal to numeric values. (One might notice that the color for x and y changes from blue to black, but my eyes have trouble seeing that for single-letter variables.) For some reason, these values are outside the domain specified in the plot. I think this must be a bug and have reported it to WRI.



          Clear[x, y]
          {x, y}
          field = {Interpolation[Range[4]^2/4][y], x};
          VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]
          {x, y}


          enter image description here



          One possible workaround is to clear the variables after plotting with Clear[x, y]. Another is to use Block:



          Block[{x, y}, VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]]


          Further, it does not seem restricted only to InterpolatingFunction. The following has the same issue, and, further, VectorStyle is ignored:



          Clear[x, y, ff]
          {x, y}
          ff[xx_, yy_] := {yy^2/4, xx};
          VectorDensityPlot[ff[x, y], {x, 1, 4}, {y, 1, 4}, VectorStyle -> Red]
          {x, y}
          (* output is the same as above, same coloring *)


          Pre-evaluating ff[x, y] gives the desired plot:



          VectorDensityPlot[Evaluate@ff[x, y], {x, 1, 4}, {y, 1, 4}, VectorStyle -> Red]





          share|improve this answer









          $endgroup$



          What is happening is that x and y are being set equal to numeric values. (One might notice that the color for x and y changes from blue to black, but my eyes have trouble seeing that for single-letter variables.) For some reason, these values are outside the domain specified in the plot. I think this must be a bug and have reported it to WRI.



          Clear[x, y]
          {x, y}
          field = {Interpolation[Range[4]^2/4][y], x};
          VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]
          {x, y}


          enter image description here



          One possible workaround is to clear the variables after plotting with Clear[x, y]. Another is to use Block:



          Block[{x, y}, VectorDensityPlot[field, {x, 1, 4}, {y, 1, 4}]]


          Further, it does not seem restricted only to InterpolatingFunction. The following has the same issue, and, further, VectorStyle is ignored:



          Clear[x, y, ff]
          {x, y}
          ff[xx_, yy_] := {yy^2/4, xx};
          VectorDensityPlot[ff[x, y], {x, 1, 4}, {y, 1, 4}, VectorStyle -> Red]
          {x, y}
          (* output is the same as above, same coloring *)


          Pre-evaluating ff[x, y] gives the desired plot:



          VectorDensityPlot[Evaluate@ff[x, y], {x, 1, 4}, {y, 1, 4}, VectorStyle -> Red]






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 6 hours ago









          Michael E2Michael E2

          148k12198475




          148k12198475























              1












              $begingroup$

              This works...once you have potdistr, run this to get a Function



              pdg = Evaluate[Grad[potdistr[#1, #2], {#1, #2}]] &


              You can then run the plot function repeatedly, no problem, and go back and run previous statements (you couldn't when x, y were getting set).



              VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]
              VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]
              VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]


              enter image description here



              You can also run this kludgy version, but it is slow.



              VectorDensityPlot[Evaluate[Grad[potdistr[#1, #2], {#1, #2}]] &[x, y], 
              {x, 0, 0.1}, {y, 0, 0.05}]


              I was interested in the not very useful looking StreamPlot I was getting.



              StreamPlot[pdg[x, y], {x, 0, 0.1}, {y, 0, 0.05}]


              enter image description here



              One thing I found odd is that if you look at the domain for potdistr versus the plot ranges people are using, there should be some extrapolation going on. Shouldn't we get warnings for that?






              share|improve this answer









              $endgroup$


















                1












                $begingroup$

                This works...once you have potdistr, run this to get a Function



                pdg = Evaluate[Grad[potdistr[#1, #2], {#1, #2}]] &


                You can then run the plot function repeatedly, no problem, and go back and run previous statements (you couldn't when x, y were getting set).



                VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]
                VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]
                VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]


                enter image description here



                You can also run this kludgy version, but it is slow.



                VectorDensityPlot[Evaluate[Grad[potdistr[#1, #2], {#1, #2}]] &[x, y], 
                {x, 0, 0.1}, {y, 0, 0.05}]


                I was interested in the not very useful looking StreamPlot I was getting.



                StreamPlot[pdg[x, y], {x, 0, 0.1}, {y, 0, 0.05}]


                enter image description here



                One thing I found odd is that if you look at the domain for potdistr versus the plot ranges people are using, there should be some extrapolation going on. Shouldn't we get warnings for that?






                share|improve this answer









                $endgroup$
















                  1












                  1








                  1





                  $begingroup$

                  This works...once you have potdistr, run this to get a Function



                  pdg = Evaluate[Grad[potdistr[#1, #2], {#1, #2}]] &


                  You can then run the plot function repeatedly, no problem, and go back and run previous statements (you couldn't when x, y were getting set).



                  VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]
                  VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]
                  VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]


                  enter image description here



                  You can also run this kludgy version, but it is slow.



                  VectorDensityPlot[Evaluate[Grad[potdistr[#1, #2], {#1, #2}]] &[x, y], 
                  {x, 0, 0.1}, {y, 0, 0.05}]


                  I was interested in the not very useful looking StreamPlot I was getting.



                  StreamPlot[pdg[x, y], {x, 0, 0.1}, {y, 0, 0.05}]


                  enter image description here



                  One thing I found odd is that if you look at the domain for potdistr versus the plot ranges people are using, there should be some extrapolation going on. Shouldn't we get warnings for that?






                  share|improve this answer









                  $endgroup$



                  This works...once you have potdistr, run this to get a Function



                  pdg = Evaluate[Grad[potdistr[#1, #2], {#1, #2}]] &


                  You can then run the plot function repeatedly, no problem, and go back and run previous statements (you couldn't when x, y were getting set).



                  VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]
                  VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]
                  VectorDensityPlot[pdg[x,y], {x, 0, 0.1}, {y, 0, 0.05}]


                  enter image description here



                  You can also run this kludgy version, but it is slow.



                  VectorDensityPlot[Evaluate[Grad[potdistr[#1, #2], {#1, #2}]] &[x, y], 
                  {x, 0, 0.1}, {y, 0, 0.05}]


                  I was interested in the not very useful looking StreamPlot I was getting.



                  StreamPlot[pdg[x, y], {x, 0, 0.1}, {y, 0, 0.05}]


                  enter image description here



                  One thing I found odd is that if you look at the domain for potdistr versus the plot ranges people are using, there should be some extrapolation going on. Shouldn't we get warnings for that?







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 24 mins ago









                  MikeYMikeY

                  3,022413




                  3,022413






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Mathematica Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      Use MathJax to format equations. MathJax reference.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192118%2fbug-in-vectorfieldplot-with-interpolatingfunction%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Szabolcs (Ungheria) Altri progetti | Menu di navigazione48°10′14.56″N 21°29′33.14″E /...

                      Discografia di Klaus Schulze Indice Album in studio | Album dal vivo | Singoli | Antologie | Colonne...

                      How to make inet_server_addr() return localhost in spite of ::1/128RETURN NEXT in Postgres FunctionConnect to...