Plot values of matrixplot as well as the matrixplot itself inside Manipulate

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












Given a MatrixPlot inside a Manipulate, say some $M(t)$ where $M_ij$ real for all entries, is there a way to show the values of each $M_ij$ inside matrix plot whilst the Manipulate runs?










share|improve this question























  • Possible duplicate mathematica.stackexchange.com/questions/9884/…
    – Okkes Dulgerci
    2 hours ago










  • Possible duplicate of ArrayPlot with cells labeled by corresponding values
    – Edmund
    1 hour ago














up vote
4
down vote

favorite












Given a MatrixPlot inside a Manipulate, say some $M(t)$ where $M_ij$ real for all entries, is there a way to show the values of each $M_ij$ inside matrix plot whilst the Manipulate runs?










share|improve this question























  • Possible duplicate mathematica.stackexchange.com/questions/9884/…
    – Okkes Dulgerci
    2 hours ago










  • Possible duplicate of ArrayPlot with cells labeled by corresponding values
    – Edmund
    1 hour ago












up vote
4
down vote

favorite









up vote
4
down vote

favorite











Given a MatrixPlot inside a Manipulate, say some $M(t)$ where $M_ij$ real for all entries, is there a way to show the values of each $M_ij$ inside matrix plot whilst the Manipulate runs?










share|improve this question















Given a MatrixPlot inside a Manipulate, say some $M(t)$ where $M_ij$ real for all entries, is there a way to show the values of each $M_ij$ inside matrix plot whilst the Manipulate runs?







graphics matrix






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









kglr

170k8193397




170k8193397










asked 3 hours ago









MKF

1314




1314











  • Possible duplicate mathematica.stackexchange.com/questions/9884/…
    – Okkes Dulgerci
    2 hours ago










  • Possible duplicate of ArrayPlot with cells labeled by corresponding values
    – Edmund
    1 hour ago
















  • Possible duplicate mathematica.stackexchange.com/questions/9884/…
    – Okkes Dulgerci
    2 hours ago










  • Possible duplicate of ArrayPlot with cells labeled by corresponding values
    – Edmund
    1 hour ago















Possible duplicate mathematica.stackexchange.com/questions/9884/…
– Okkes Dulgerci
2 hours ago




Possible duplicate mathematica.stackexchange.com/questions/9884/…
– Okkes Dulgerci
2 hours ago












Possible duplicate of ArrayPlot with cells labeled by corresponding values
– Edmund
1 hour ago




Possible duplicate of ArrayPlot with cells labeled by corresponding values
– Edmund
1 hour ago










2 Answers
2






active

oldest

votes

















up vote
2
down vote













Here is using Graphics



SeedRandom@2;
matrix = RandomInteger[10, 5, 5];
MatrixForm@matrix



$left(beginarrayccccc
8 & 4 & 5 & 4 & 7 \
4 & 0 & 1 & 0 & 4 \
3 & 7 & 3 & 0 & 2 \
7 & 8 & 7 & 9 & 3 \
6 & 2 & 3 & 8 & 9 \
endarrayright)$




data = Join @@ Reverse@Table[i, j, j, 5, i, 1, 5];
values = Flatten@matrix;
minMax = MinMax@values;
data2 = Flatten /@ Partition[Riffle[values, data], 2];

Legended[Graphics[EdgeForm[Black],
ColorData["DarkRainbow"][Rescale[First[#], minMax]],
Rectangle[Rest[#]], Black,
Text[First[#], Rest[#] + 0.5, 0.5] & /@ data2],
BarLegend["DarkRainbow", minMax]]


enter image description here



If you want to use MatrixPlot



Overlay[MatrixPlot[matrix, PlotRangePadding -> None, 
ImagePadding -> None],
Graphics[Opacity@0, Rectangle[Rest[#]], Opacity@1, Black,
Text[First[#], Rest[#] + 0.5, 0.5] & /@ data2,
PlotRangePadding -> None]]


enter image description here






share|improve this answer



























    up vote
    2
    down vote













    Using a Slider to change the dimensions of the matrix and EventHandler to increase (left mouse click) / decrease (right mouse click) values of matrix elements:



    DynamicModule[m = ConstantArray[0, 20, 20],
    Manipulate[mat = m[[;; n, ;; n]];
    Dynamic@EventHandler[
    MatrixPlot[mat, Mesh -> All, ImageSize -> 1 -> 50,
    DataReversed -> True,
    Epilog -> Dynamic[MapIndexed[Text[Style[#, Large], Reverse@#2 - .5] &, mat, 2]]],
    "MouseClicked", 1 :> With[p = Reverse @ Ceiling @ MousePosition["Graphics"],
    m[[## & @@ p]] += 1],
    "MouseClicked", 2 :> With[p = Reverse @ Ceiling @ MousePosition["Graphics"],
    m[[## & @@ p]] -= 1]],
    n, 5, 2, 20, 1]]


    enter image description here



    enter image description here






    share|improve this answer






















      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',
      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%2f185720%2fplot-values-of-matrixplot-as-well-as-the-matrixplot-itself-inside-manipulate%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote













      Here is using Graphics



      SeedRandom@2;
      matrix = RandomInteger[10, 5, 5];
      MatrixForm@matrix



      $left(beginarrayccccc
      8 & 4 & 5 & 4 & 7 \
      4 & 0 & 1 & 0 & 4 \
      3 & 7 & 3 & 0 & 2 \
      7 & 8 & 7 & 9 & 3 \
      6 & 2 & 3 & 8 & 9 \
      endarrayright)$




      data = Join @@ Reverse@Table[i, j, j, 5, i, 1, 5];
      values = Flatten@matrix;
      minMax = MinMax@values;
      data2 = Flatten /@ Partition[Riffle[values, data], 2];

      Legended[Graphics[EdgeForm[Black],
      ColorData["DarkRainbow"][Rescale[First[#], minMax]],
      Rectangle[Rest[#]], Black,
      Text[First[#], Rest[#] + 0.5, 0.5] & /@ data2],
      BarLegend["DarkRainbow", minMax]]


      enter image description here



      If you want to use MatrixPlot



      Overlay[MatrixPlot[matrix, PlotRangePadding -> None, 
      ImagePadding -> None],
      Graphics[Opacity@0, Rectangle[Rest[#]], Opacity@1, Black,
      Text[First[#], Rest[#] + 0.5, 0.5] & /@ data2,
      PlotRangePadding -> None]]


      enter image description here






      share|improve this answer
























        up vote
        2
        down vote













        Here is using Graphics



        SeedRandom@2;
        matrix = RandomInteger[10, 5, 5];
        MatrixForm@matrix



        $left(beginarrayccccc
        8 & 4 & 5 & 4 & 7 \
        4 & 0 & 1 & 0 & 4 \
        3 & 7 & 3 & 0 & 2 \
        7 & 8 & 7 & 9 & 3 \
        6 & 2 & 3 & 8 & 9 \
        endarrayright)$




        data = Join @@ Reverse@Table[i, j, j, 5, i, 1, 5];
        values = Flatten@matrix;
        minMax = MinMax@values;
        data2 = Flatten /@ Partition[Riffle[values, data], 2];

        Legended[Graphics[EdgeForm[Black],
        ColorData["DarkRainbow"][Rescale[First[#], minMax]],
        Rectangle[Rest[#]], Black,
        Text[First[#], Rest[#] + 0.5, 0.5] & /@ data2],
        BarLegend["DarkRainbow", minMax]]


        enter image description here



        If you want to use MatrixPlot



        Overlay[MatrixPlot[matrix, PlotRangePadding -> None, 
        ImagePadding -> None],
        Graphics[Opacity@0, Rectangle[Rest[#]], Opacity@1, Black,
        Text[First[#], Rest[#] + 0.5, 0.5] & /@ data2,
        PlotRangePadding -> None]]


        enter image description here






        share|improve this answer






















          up vote
          2
          down vote










          up vote
          2
          down vote









          Here is using Graphics



          SeedRandom@2;
          matrix = RandomInteger[10, 5, 5];
          MatrixForm@matrix



          $left(beginarrayccccc
          8 & 4 & 5 & 4 & 7 \
          4 & 0 & 1 & 0 & 4 \
          3 & 7 & 3 & 0 & 2 \
          7 & 8 & 7 & 9 & 3 \
          6 & 2 & 3 & 8 & 9 \
          endarrayright)$




          data = Join @@ Reverse@Table[i, j, j, 5, i, 1, 5];
          values = Flatten@matrix;
          minMax = MinMax@values;
          data2 = Flatten /@ Partition[Riffle[values, data], 2];

          Legended[Graphics[EdgeForm[Black],
          ColorData["DarkRainbow"][Rescale[First[#], minMax]],
          Rectangle[Rest[#]], Black,
          Text[First[#], Rest[#] + 0.5, 0.5] & /@ data2],
          BarLegend["DarkRainbow", minMax]]


          enter image description here



          If you want to use MatrixPlot



          Overlay[MatrixPlot[matrix, PlotRangePadding -> None, 
          ImagePadding -> None],
          Graphics[Opacity@0, Rectangle[Rest[#]], Opacity@1, Black,
          Text[First[#], Rest[#] + 0.5, 0.5] & /@ data2,
          PlotRangePadding -> None]]


          enter image description here






          share|improve this answer












          Here is using Graphics



          SeedRandom@2;
          matrix = RandomInteger[10, 5, 5];
          MatrixForm@matrix



          $left(beginarrayccccc
          8 & 4 & 5 & 4 & 7 \
          4 & 0 & 1 & 0 & 4 \
          3 & 7 & 3 & 0 & 2 \
          7 & 8 & 7 & 9 & 3 \
          6 & 2 & 3 & 8 & 9 \
          endarrayright)$




          data = Join @@ Reverse@Table[i, j, j, 5, i, 1, 5];
          values = Flatten@matrix;
          minMax = MinMax@values;
          data2 = Flatten /@ Partition[Riffle[values, data], 2];

          Legended[Graphics[EdgeForm[Black],
          ColorData["DarkRainbow"][Rescale[First[#], minMax]],
          Rectangle[Rest[#]], Black,
          Text[First[#], Rest[#] + 0.5, 0.5] & /@ data2],
          BarLegend["DarkRainbow", minMax]]


          enter image description here



          If you want to use MatrixPlot



          Overlay[MatrixPlot[matrix, PlotRangePadding -> None, 
          ImagePadding -> None],
          Graphics[Opacity@0, Rectangle[Rest[#]], Opacity@1, Black,
          Text[First[#], Rest[#] + 0.5, 0.5] & /@ data2,
          PlotRangePadding -> None]]


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 hours ago









          Okkes Dulgerci

          3,4461716




          3,4461716




















              up vote
              2
              down vote













              Using a Slider to change the dimensions of the matrix and EventHandler to increase (left mouse click) / decrease (right mouse click) values of matrix elements:



              DynamicModule[m = ConstantArray[0, 20, 20],
              Manipulate[mat = m[[;; n, ;; n]];
              Dynamic@EventHandler[
              MatrixPlot[mat, Mesh -> All, ImageSize -> 1 -> 50,
              DataReversed -> True,
              Epilog -> Dynamic[MapIndexed[Text[Style[#, Large], Reverse@#2 - .5] &, mat, 2]]],
              "MouseClicked", 1 :> With[p = Reverse @ Ceiling @ MousePosition["Graphics"],
              m[[## & @@ p]] += 1],
              "MouseClicked", 2 :> With[p = Reverse @ Ceiling @ MousePosition["Graphics"],
              m[[## & @@ p]] -= 1]],
              n, 5, 2, 20, 1]]


              enter image description here



              enter image description here






              share|improve this answer


























                up vote
                2
                down vote













                Using a Slider to change the dimensions of the matrix and EventHandler to increase (left mouse click) / decrease (right mouse click) values of matrix elements:



                DynamicModule[m = ConstantArray[0, 20, 20],
                Manipulate[mat = m[[;; n, ;; n]];
                Dynamic@EventHandler[
                MatrixPlot[mat, Mesh -> All, ImageSize -> 1 -> 50,
                DataReversed -> True,
                Epilog -> Dynamic[MapIndexed[Text[Style[#, Large], Reverse@#2 - .5] &, mat, 2]]],
                "MouseClicked", 1 :> With[p = Reverse @ Ceiling @ MousePosition["Graphics"],
                m[[## & @@ p]] += 1],
                "MouseClicked", 2 :> With[p = Reverse @ Ceiling @ MousePosition["Graphics"],
                m[[## & @@ p]] -= 1]],
                n, 5, 2, 20, 1]]


                enter image description here



                enter image description here






                share|improve this answer
























                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  Using a Slider to change the dimensions of the matrix and EventHandler to increase (left mouse click) / decrease (right mouse click) values of matrix elements:



                  DynamicModule[m = ConstantArray[0, 20, 20],
                  Manipulate[mat = m[[;; n, ;; n]];
                  Dynamic@EventHandler[
                  MatrixPlot[mat, Mesh -> All, ImageSize -> 1 -> 50,
                  DataReversed -> True,
                  Epilog -> Dynamic[MapIndexed[Text[Style[#, Large], Reverse@#2 - .5] &, mat, 2]]],
                  "MouseClicked", 1 :> With[p = Reverse @ Ceiling @ MousePosition["Graphics"],
                  m[[## & @@ p]] += 1],
                  "MouseClicked", 2 :> With[p = Reverse @ Ceiling @ MousePosition["Graphics"],
                  m[[## & @@ p]] -= 1]],
                  n, 5, 2, 20, 1]]


                  enter image description here



                  enter image description here






                  share|improve this answer














                  Using a Slider to change the dimensions of the matrix and EventHandler to increase (left mouse click) / decrease (right mouse click) values of matrix elements:



                  DynamicModule[m = ConstantArray[0, 20, 20],
                  Manipulate[mat = m[[;; n, ;; n]];
                  Dynamic@EventHandler[
                  MatrixPlot[mat, Mesh -> All, ImageSize -> 1 -> 50,
                  DataReversed -> True,
                  Epilog -> Dynamic[MapIndexed[Text[Style[#, Large], Reverse@#2 - .5] &, mat, 2]]],
                  "MouseClicked", 1 :> With[p = Reverse @ Ceiling @ MousePosition["Graphics"],
                  m[[## & @@ p]] += 1],
                  "MouseClicked", 2 :> With[p = Reverse @ Ceiling @ MousePosition["Graphics"],
                  m[[## & @@ p]] -= 1]],
                  n, 5, 2, 20, 1]]


                  enter image description here



                  enter image description here







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 1 hour ago

























                  answered 1 hour ago









                  kglr

                  170k8193397




                  170k8193397



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185720%2fplot-values-of-matrixplot-as-well-as-the-matrixplot-itself-inside-manipulate%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      Installing NextGIS Connect into QGIS 3?

                      One-line joke