How to plot an integer with a specific color for each digit?

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











up vote
8
down vote

favorite
1












I want to plot something like this, the first 100,000 digits of Pi: enter image description here



... in a rectangular or circular form.







share|improve this question









New contributor




mhd.math is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 1




    Welcome to Mathematica.SE! You should watch the introductory Tour to get the basics of the site.
    – Vitaliy Kaurov
    Sep 5 at 19:21











  • @VitaliyKaurov Thank You for the welcoming and your answer, I appreciate your efforts.
    – mhd.math
    Sep 5 at 19:25











  • For plotting PI, the circular form should be logical. But it would be interesting to find out if such a plot for other irrational numbers (e, sqrt(2)) pr just random numbers, would look different
    – Roland
    Sep 6 at 11:02














up vote
8
down vote

favorite
1












I want to plot something like this, the first 100,000 digits of Pi: enter image description here



... in a rectangular or circular form.







share|improve this question









New contributor




mhd.math is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 1




    Welcome to Mathematica.SE! You should watch the introductory Tour to get the basics of the site.
    – Vitaliy Kaurov
    Sep 5 at 19:21











  • @VitaliyKaurov Thank You for the welcoming and your answer, I appreciate your efforts.
    – mhd.math
    Sep 5 at 19:25











  • For plotting PI, the circular form should be logical. But it would be interesting to find out if such a plot for other irrational numbers (e, sqrt(2)) pr just random numbers, would look different
    – Roland
    Sep 6 at 11:02












up vote
8
down vote

favorite
1









up vote
8
down vote

favorite
1






1





I want to plot something like this, the first 100,000 digits of Pi: enter image description here



... in a rectangular or circular form.







share|improve this question









New contributor




mhd.math is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










I want to plot something like this, the first 100,000 digits of Pi: enter image description here



... in a rectangular or circular form.









share|improve this question









New contributor




mhd.math is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Sep 5 at 18:41









Johu

2,636829




2,636829






New contributor




mhd.math is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Sep 5 at 18:30









mhd.math

1434




1434




New contributor




mhd.math is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





mhd.math is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






mhd.math is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1




    Welcome to Mathematica.SE! You should watch the introductory Tour to get the basics of the site.
    – Vitaliy Kaurov
    Sep 5 at 19:21











  • @VitaliyKaurov Thank You for the welcoming and your answer, I appreciate your efforts.
    – mhd.math
    Sep 5 at 19:25











  • For plotting PI, the circular form should be logical. But it would be interesting to find out if such a plot for other irrational numbers (e, sqrt(2)) pr just random numbers, would look different
    – Roland
    Sep 6 at 11:02












  • 1




    Welcome to Mathematica.SE! You should watch the introductory Tour to get the basics of the site.
    – Vitaliy Kaurov
    Sep 5 at 19:21











  • @VitaliyKaurov Thank You for the welcoming and your answer, I appreciate your efforts.
    – mhd.math
    Sep 5 at 19:25











  • For plotting PI, the circular form should be logical. But it would be interesting to find out if such a plot for other irrational numbers (e, sqrt(2)) pr just random numbers, would look different
    – Roland
    Sep 6 at 11:02







1




1




Welcome to Mathematica.SE! You should watch the introductory Tour to get the basics of the site.
– Vitaliy Kaurov
Sep 5 at 19:21





Welcome to Mathematica.SE! You should watch the introductory Tour to get the basics of the site.
– Vitaliy Kaurov
Sep 5 at 19:21













@VitaliyKaurov Thank You for the welcoming and your answer, I appreciate your efforts.
– mhd.math
Sep 5 at 19:25





@VitaliyKaurov Thank You for the welcoming and your answer, I appreciate your efforts.
– mhd.math
Sep 5 at 19:25













For plotting PI, the circular form should be logical. But it would be interesting to find out if such a plot for other irrational numbers (e, sqrt(2)) pr just random numbers, would look different
– Roland
Sep 6 at 11:02




For plotting PI, the circular form should be logical. But it would be interesting to find out if such a plot for other irrational numbers (e, sqrt(2)) pr just random numbers, would look different
– Roland
Sep 6 at 11:02










4 Answers
4






active

oldest

votes

















up vote
9
down vote



accepted










Before asking for help you should always try your own solution and post the code that you have tried (see docs and EIWL), even if you cannot finish it, it's a good etiquette :-) (please do that in future). But you are new user and this problem have a nice minimal solution in Wolfram Language, so I post my take on it.



Your colors look like Hue (or HSB), I will use that and transfer to RGB:



colors = ColorConvert[Hue /@ Range[0, .9, .1], "RGB"]


enter image description here



Build rules for replacement of a digit by color:



rules = Dispatch[Thread[Range[0, 9] -> List @@@ colors]]


Build image. You are basically building a matrix partitioning Pi digits list into a matrix, and then replacing in that matrix digits by RGB values. And that is the array structure of an Image which is efficient in this case, I think, more than Graphics. You can partition at a different than 400 width to achieve different aspect ratio.



Image[Partition[First[RealDigits[Pi, 10, 100000]], 400] /. rules]


enter image description here






share|improve this answer





























    up vote
    8
    down vote













    You mentioned plotting the digits of Pi in a "circular form". Perhaps a "sunflower" plot is of interest. Digits are plotted in a spiral from the centre outwards, and coloured by the chosen colour scheme. As the rational approximation to Pi gets better, that is, as exponent k increases, patterns in the plot disappear. A visual confirmation of the randomness of the digits.



    This function plots a sunflower with each disk having the property accorded by the function f.



    SunflowerPlot[n_, c_, d_, phi_, f_, cs_String] :=
    Graphics[
    Table[
    ColorData[cs, f[k]],
    Disk[c Sqrt[k] Cos[k phi Degree], Sin[k phi Degree], d],
    k, 1, n]]


    The plot may be manipulated with the following.



    Manipulate[
    SunflowerPlot[n, c, d, phi,
    ((RealDigits[Rationalize[Pi, 10.^-k], 10, 2500][[1]][[#]]*0.1)^e &),
    cs],
    n, 1000, "Number of Florets", 10, 2500, 10, Appearance -> "Labeled",
    c, 0.2, "Scaling Parameter", 0.1, 0.5, Appearance -> "Labeled",
    d, 0.2, "Floret Radius", 0.1, 0.5, Appearance -> "Labeled",
    k, 5., "Rationalize Exponent", 1., 15., Appearance -> "Labeled",
    phi, 137.50776405, "Spiral Angle", 10, 360, Appearance -> "Labeled",
    cs, "SolarColors", "Colour Scheme", ColorData["Gradients"],
    e, 1.0, "Colour Exponent", 0.1, 3.0, Appearance -> "Labeled"]


    sunflowers






    share|improve this answer



























      up vote
      6
      down vote













      You can also use MatrixPlot:



      legend = Graphics[Hue[#/10], Disk[#, 0, .5], Black, 
      Text[Style[#, 16], #, 0] & /@ Range[0, 9], ImageSize -> 300];
      MatrixPlot[Partition[First[RealDigits[Pi, 10, 100000]], 400],
      ColorFunction -> ( Hue[#/10] &), ColorFunctionScaling -> False,
      Frame -> False, ImageSize -> 2 -> 3, PlotLegends -> Placed[legend, Below]]


      enter image description here



      Alternatively, use an array of colors as the first argument of MatrixPlot:



      MatrixPlot[Map[Hue[#/10] &, Partition[First[RealDigits[Pi, 10, 100000]], 400], -1],
      Frame -> False, ImageSize -> 2 -> 3,
      PlotLegends -> Placed[legend, Below]]



      same picture







      share|improve this answer





























        up vote
        4
        down vote













        Small 10 x 5 version showing the first 50 digits of Pi



        colours = Transpose@Reverse@Partition[Characters[
        "3" <> StringDrop[ToString[N[Pi, 50]], 2]], 10];
        insets = Table[Inset[Style[Text[colours[[i + 1, j + 1]]],
        Black, FontSize -> 20],
        10 i, 10 j, 0, 0, 10, 10], i, 0, 10 - 1, j, 0, 5 - 1];
        Graphics[Yellow, Rectangle[0, 0, 100, 50], insets]


        Same again with colours



        colours = Transpose@Reverse@Partition[Characters[
        "3" <> StringDrop[ToString[N[Pi, 50]], 2]] /. Thread[
        ToString /@ Range[0, 9] -> ColorData[3, "ColorList"]], 10];
        insets = Table[Inset[Graphics[colours[[i + 1, j + 1]],
        Rectangle[0, 0, 10, 10],
        PlotRange -> 0, 10, 0, 10, ImageSize -> 10],
        10 i, 10 j, 0, 0, 10, 10], i, 0, 10 - 1, j, 0, 5 - 1];
        Graphics[Yellow, Rectangle[0, 0, 100, 50],
        insets, PlotRange -> 0, 100, 0, 50]


        Similar version showing the first 5000 characters of Pi



        colours = Transpose@Reverse@Partition[Characters[
        "3" <> StringDrop[ToString[N[Pi, 5000]], 2]] /. Thread[
        ToString /@ Range[0, 9] -> ColorData[3, "ColorList"]], 100];
        insets = Table[Inset[Graphics[colours[[i + 1, j + 1]],
        Rectangle[0, 0, 10, 10],
        PlotRange -> 0, 10, 0, 10, ImageSize -> 10],
        10 i, 10 j, 0, 0, 10, 10], i, 0, 100 - 1, j, 0, 50 - 1];
        Graphics[Yellow, Rectangle[0, 0, 1000, 500],
        insets, PlotRange -> 0, 1000, 0, 500]


        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: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          mhd.math is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181293%2fhow-to-plot-an-integer-with-a-specific-color-for-each-digit%23new-answer', 'question_page');

          );

          Post as a guest






























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          9
          down vote



          accepted










          Before asking for help you should always try your own solution and post the code that you have tried (see docs and EIWL), even if you cannot finish it, it's a good etiquette :-) (please do that in future). But you are new user and this problem have a nice minimal solution in Wolfram Language, so I post my take on it.



          Your colors look like Hue (or HSB), I will use that and transfer to RGB:



          colors = ColorConvert[Hue /@ Range[0, .9, .1], "RGB"]


          enter image description here



          Build rules for replacement of a digit by color:



          rules = Dispatch[Thread[Range[0, 9] -> List @@@ colors]]


          Build image. You are basically building a matrix partitioning Pi digits list into a matrix, and then replacing in that matrix digits by RGB values. And that is the array structure of an Image which is efficient in this case, I think, more than Graphics. You can partition at a different than 400 width to achieve different aspect ratio.



          Image[Partition[First[RealDigits[Pi, 10, 100000]], 400] /. rules]


          enter image description here






          share|improve this answer


























            up vote
            9
            down vote



            accepted










            Before asking for help you should always try your own solution and post the code that you have tried (see docs and EIWL), even if you cannot finish it, it's a good etiquette :-) (please do that in future). But you are new user and this problem have a nice minimal solution in Wolfram Language, so I post my take on it.



            Your colors look like Hue (or HSB), I will use that and transfer to RGB:



            colors = ColorConvert[Hue /@ Range[0, .9, .1], "RGB"]


            enter image description here



            Build rules for replacement of a digit by color:



            rules = Dispatch[Thread[Range[0, 9] -> List @@@ colors]]


            Build image. You are basically building a matrix partitioning Pi digits list into a matrix, and then replacing in that matrix digits by RGB values. And that is the array structure of an Image which is efficient in this case, I think, more than Graphics. You can partition at a different than 400 width to achieve different aspect ratio.



            Image[Partition[First[RealDigits[Pi, 10, 100000]], 400] /. rules]


            enter image description here






            share|improve this answer
























              up vote
              9
              down vote



              accepted







              up vote
              9
              down vote



              accepted






              Before asking for help you should always try your own solution and post the code that you have tried (see docs and EIWL), even if you cannot finish it, it's a good etiquette :-) (please do that in future). But you are new user and this problem have a nice minimal solution in Wolfram Language, so I post my take on it.



              Your colors look like Hue (or HSB), I will use that and transfer to RGB:



              colors = ColorConvert[Hue /@ Range[0, .9, .1], "RGB"]


              enter image description here



              Build rules for replacement of a digit by color:



              rules = Dispatch[Thread[Range[0, 9] -> List @@@ colors]]


              Build image. You are basically building a matrix partitioning Pi digits list into a matrix, and then replacing in that matrix digits by RGB values. And that is the array structure of an Image which is efficient in this case, I think, more than Graphics. You can partition at a different than 400 width to achieve different aspect ratio.



              Image[Partition[First[RealDigits[Pi, 10, 100000]], 400] /. rules]


              enter image description here






              share|improve this answer














              Before asking for help you should always try your own solution and post the code that you have tried (see docs and EIWL), even if you cannot finish it, it's a good etiquette :-) (please do that in future). But you are new user and this problem have a nice minimal solution in Wolfram Language, so I post my take on it.



              Your colors look like Hue (or HSB), I will use that and transfer to RGB:



              colors = ColorConvert[Hue /@ Range[0, .9, .1], "RGB"]


              enter image description here



              Build rules for replacement of a digit by color:



              rules = Dispatch[Thread[Range[0, 9] -> List @@@ colors]]


              Build image. You are basically building a matrix partitioning Pi digits list into a matrix, and then replacing in that matrix digits by RGB values. And that is the array structure of an Image which is efficient in this case, I think, more than Graphics. You can partition at a different than 400 width to achieve different aspect ratio.



              Image[Partition[First[RealDigits[Pi, 10, 100000]], 400] /. rules]


              enter image description here







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Sep 5 at 19:16

























              answered Sep 5 at 19:04









              Vitaliy Kaurov

              55.4k6155269




              55.4k6155269




















                  up vote
                  8
                  down vote













                  You mentioned plotting the digits of Pi in a "circular form". Perhaps a "sunflower" plot is of interest. Digits are plotted in a spiral from the centre outwards, and coloured by the chosen colour scheme. As the rational approximation to Pi gets better, that is, as exponent k increases, patterns in the plot disappear. A visual confirmation of the randomness of the digits.



                  This function plots a sunflower with each disk having the property accorded by the function f.



                  SunflowerPlot[n_, c_, d_, phi_, f_, cs_String] :=
                  Graphics[
                  Table[
                  ColorData[cs, f[k]],
                  Disk[c Sqrt[k] Cos[k phi Degree], Sin[k phi Degree], d],
                  k, 1, n]]


                  The plot may be manipulated with the following.



                  Manipulate[
                  SunflowerPlot[n, c, d, phi,
                  ((RealDigits[Rationalize[Pi, 10.^-k], 10, 2500][[1]][[#]]*0.1)^e &),
                  cs],
                  n, 1000, "Number of Florets", 10, 2500, 10, Appearance -> "Labeled",
                  c, 0.2, "Scaling Parameter", 0.1, 0.5, Appearance -> "Labeled",
                  d, 0.2, "Floret Radius", 0.1, 0.5, Appearance -> "Labeled",
                  k, 5., "Rationalize Exponent", 1., 15., Appearance -> "Labeled",
                  phi, 137.50776405, "Spiral Angle", 10, 360, Appearance -> "Labeled",
                  cs, "SolarColors", "Colour Scheme", ColorData["Gradients"],
                  e, 1.0, "Colour Exponent", 0.1, 3.0, Appearance -> "Labeled"]


                  sunflowers






                  share|improve this answer
























                    up vote
                    8
                    down vote













                    You mentioned plotting the digits of Pi in a "circular form". Perhaps a "sunflower" plot is of interest. Digits are plotted in a spiral from the centre outwards, and coloured by the chosen colour scheme. As the rational approximation to Pi gets better, that is, as exponent k increases, patterns in the plot disappear. A visual confirmation of the randomness of the digits.



                    This function plots a sunflower with each disk having the property accorded by the function f.



                    SunflowerPlot[n_, c_, d_, phi_, f_, cs_String] :=
                    Graphics[
                    Table[
                    ColorData[cs, f[k]],
                    Disk[c Sqrt[k] Cos[k phi Degree], Sin[k phi Degree], d],
                    k, 1, n]]


                    The plot may be manipulated with the following.



                    Manipulate[
                    SunflowerPlot[n, c, d, phi,
                    ((RealDigits[Rationalize[Pi, 10.^-k], 10, 2500][[1]][[#]]*0.1)^e &),
                    cs],
                    n, 1000, "Number of Florets", 10, 2500, 10, Appearance -> "Labeled",
                    c, 0.2, "Scaling Parameter", 0.1, 0.5, Appearance -> "Labeled",
                    d, 0.2, "Floret Radius", 0.1, 0.5, Appearance -> "Labeled",
                    k, 5., "Rationalize Exponent", 1., 15., Appearance -> "Labeled",
                    phi, 137.50776405, "Spiral Angle", 10, 360, Appearance -> "Labeled",
                    cs, "SolarColors", "Colour Scheme", ColorData["Gradients"],
                    e, 1.0, "Colour Exponent", 0.1, 3.0, Appearance -> "Labeled"]


                    sunflowers






                    share|improve this answer






















                      up vote
                      8
                      down vote










                      up vote
                      8
                      down vote









                      You mentioned plotting the digits of Pi in a "circular form". Perhaps a "sunflower" plot is of interest. Digits are plotted in a spiral from the centre outwards, and coloured by the chosen colour scheme. As the rational approximation to Pi gets better, that is, as exponent k increases, patterns in the plot disappear. A visual confirmation of the randomness of the digits.



                      This function plots a sunflower with each disk having the property accorded by the function f.



                      SunflowerPlot[n_, c_, d_, phi_, f_, cs_String] :=
                      Graphics[
                      Table[
                      ColorData[cs, f[k]],
                      Disk[c Sqrt[k] Cos[k phi Degree], Sin[k phi Degree], d],
                      k, 1, n]]


                      The plot may be manipulated with the following.



                      Manipulate[
                      SunflowerPlot[n, c, d, phi,
                      ((RealDigits[Rationalize[Pi, 10.^-k], 10, 2500][[1]][[#]]*0.1)^e &),
                      cs],
                      n, 1000, "Number of Florets", 10, 2500, 10, Appearance -> "Labeled",
                      c, 0.2, "Scaling Parameter", 0.1, 0.5, Appearance -> "Labeled",
                      d, 0.2, "Floret Radius", 0.1, 0.5, Appearance -> "Labeled",
                      k, 5., "Rationalize Exponent", 1., 15., Appearance -> "Labeled",
                      phi, 137.50776405, "Spiral Angle", 10, 360, Appearance -> "Labeled",
                      cs, "SolarColors", "Colour Scheme", ColorData["Gradients"],
                      e, 1.0, "Colour Exponent", 0.1, 3.0, Appearance -> "Labeled"]


                      sunflowers






                      share|improve this answer












                      You mentioned plotting the digits of Pi in a "circular form". Perhaps a "sunflower" plot is of interest. Digits are plotted in a spiral from the centre outwards, and coloured by the chosen colour scheme. As the rational approximation to Pi gets better, that is, as exponent k increases, patterns in the plot disappear. A visual confirmation of the randomness of the digits.



                      This function plots a sunflower with each disk having the property accorded by the function f.



                      SunflowerPlot[n_, c_, d_, phi_, f_, cs_String] :=
                      Graphics[
                      Table[
                      ColorData[cs, f[k]],
                      Disk[c Sqrt[k] Cos[k phi Degree], Sin[k phi Degree], d],
                      k, 1, n]]


                      The plot may be manipulated with the following.



                      Manipulate[
                      SunflowerPlot[n, c, d, phi,
                      ((RealDigits[Rationalize[Pi, 10.^-k], 10, 2500][[1]][[#]]*0.1)^e &),
                      cs],
                      n, 1000, "Number of Florets", 10, 2500, 10, Appearance -> "Labeled",
                      c, 0.2, "Scaling Parameter", 0.1, 0.5, Appearance -> "Labeled",
                      d, 0.2, "Floret Radius", 0.1, 0.5, Appearance -> "Labeled",
                      k, 5., "Rationalize Exponent", 1., 15., Appearance -> "Labeled",
                      phi, 137.50776405, "Spiral Angle", 10, 360, Appearance -> "Labeled",
                      cs, "SolarColors", "Colour Scheme", ColorData["Gradients"],
                      e, 1.0, "Colour Exponent", 0.1, 3.0, Appearance -> "Labeled"]


                      sunflowers







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Sep 6 at 3:20









                      KennyColnago

                      11.6k1753




                      11.6k1753




















                          up vote
                          6
                          down vote













                          You can also use MatrixPlot:



                          legend = Graphics[Hue[#/10], Disk[#, 0, .5], Black, 
                          Text[Style[#, 16], #, 0] & /@ Range[0, 9], ImageSize -> 300];
                          MatrixPlot[Partition[First[RealDigits[Pi, 10, 100000]], 400],
                          ColorFunction -> ( Hue[#/10] &), ColorFunctionScaling -> False,
                          Frame -> False, ImageSize -> 2 -> 3, PlotLegends -> Placed[legend, Below]]


                          enter image description here



                          Alternatively, use an array of colors as the first argument of MatrixPlot:



                          MatrixPlot[Map[Hue[#/10] &, Partition[First[RealDigits[Pi, 10, 100000]], 400], -1],
                          Frame -> False, ImageSize -> 2 -> 3,
                          PlotLegends -> Placed[legend, Below]]



                          same picture







                          share|improve this answer


























                            up vote
                            6
                            down vote













                            You can also use MatrixPlot:



                            legend = Graphics[Hue[#/10], Disk[#, 0, .5], Black, 
                            Text[Style[#, 16], #, 0] & /@ Range[0, 9], ImageSize -> 300];
                            MatrixPlot[Partition[First[RealDigits[Pi, 10, 100000]], 400],
                            ColorFunction -> ( Hue[#/10] &), ColorFunctionScaling -> False,
                            Frame -> False, ImageSize -> 2 -> 3, PlotLegends -> Placed[legend, Below]]


                            enter image description here



                            Alternatively, use an array of colors as the first argument of MatrixPlot:



                            MatrixPlot[Map[Hue[#/10] &, Partition[First[RealDigits[Pi, 10, 100000]], 400], -1],
                            Frame -> False, ImageSize -> 2 -> 3,
                            PlotLegends -> Placed[legend, Below]]



                            same picture







                            share|improve this answer
























                              up vote
                              6
                              down vote










                              up vote
                              6
                              down vote









                              You can also use MatrixPlot:



                              legend = Graphics[Hue[#/10], Disk[#, 0, .5], Black, 
                              Text[Style[#, 16], #, 0] & /@ Range[0, 9], ImageSize -> 300];
                              MatrixPlot[Partition[First[RealDigits[Pi, 10, 100000]], 400],
                              ColorFunction -> ( Hue[#/10] &), ColorFunctionScaling -> False,
                              Frame -> False, ImageSize -> 2 -> 3, PlotLegends -> Placed[legend, Below]]


                              enter image description here



                              Alternatively, use an array of colors as the first argument of MatrixPlot:



                              MatrixPlot[Map[Hue[#/10] &, Partition[First[RealDigits[Pi, 10, 100000]], 400], -1],
                              Frame -> False, ImageSize -> 2 -> 3,
                              PlotLegends -> Placed[legend, Below]]



                              same picture







                              share|improve this answer














                              You can also use MatrixPlot:



                              legend = Graphics[Hue[#/10], Disk[#, 0, .5], Black, 
                              Text[Style[#, 16], #, 0] & /@ Range[0, 9], ImageSize -> 300];
                              MatrixPlot[Partition[First[RealDigits[Pi, 10, 100000]], 400],
                              ColorFunction -> ( Hue[#/10] &), ColorFunctionScaling -> False,
                              Frame -> False, ImageSize -> 2 -> 3, PlotLegends -> Placed[legend, Below]]


                              enter image description here



                              Alternatively, use an array of colors as the first argument of MatrixPlot:



                              MatrixPlot[Map[Hue[#/10] &, Partition[First[RealDigits[Pi, 10, 100000]], 400], -1],
                              Frame -> False, ImageSize -> 2 -> 3,
                              PlotLegends -> Placed[legend, Below]]



                              same picture








                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Sep 5 at 23:15

























                              answered Sep 5 at 20:03









                              kglr

                              159k8183383




                              159k8183383




















                                  up vote
                                  4
                                  down vote













                                  Small 10 x 5 version showing the first 50 digits of Pi



                                  colours = Transpose@Reverse@Partition[Characters[
                                  "3" <> StringDrop[ToString[N[Pi, 50]], 2]], 10];
                                  insets = Table[Inset[Style[Text[colours[[i + 1, j + 1]]],
                                  Black, FontSize -> 20],
                                  10 i, 10 j, 0, 0, 10, 10], i, 0, 10 - 1, j, 0, 5 - 1];
                                  Graphics[Yellow, Rectangle[0, 0, 100, 50], insets]


                                  Same again with colours



                                  colours = Transpose@Reverse@Partition[Characters[
                                  "3" <> StringDrop[ToString[N[Pi, 50]], 2]] /. Thread[
                                  ToString /@ Range[0, 9] -> ColorData[3, "ColorList"]], 10];
                                  insets = Table[Inset[Graphics[colours[[i + 1, j + 1]],
                                  Rectangle[0, 0, 10, 10],
                                  PlotRange -> 0, 10, 0, 10, ImageSize -> 10],
                                  10 i, 10 j, 0, 0, 10, 10], i, 0, 10 - 1, j, 0, 5 - 1];
                                  Graphics[Yellow, Rectangle[0, 0, 100, 50],
                                  insets, PlotRange -> 0, 100, 0, 50]


                                  Similar version showing the first 5000 characters of Pi



                                  colours = Transpose@Reverse@Partition[Characters[
                                  "3" <> StringDrop[ToString[N[Pi, 5000]], 2]] /. Thread[
                                  ToString /@ Range[0, 9] -> ColorData[3, "ColorList"]], 100];
                                  insets = Table[Inset[Graphics[colours[[i + 1, j + 1]],
                                  Rectangle[0, 0, 10, 10],
                                  PlotRange -> 0, 10, 0, 10, ImageSize -> 10],
                                  10 i, 10 j, 0, 0, 10, 10], i, 0, 100 - 1, j, 0, 50 - 1];
                                  Graphics[Yellow, Rectangle[0, 0, 1000, 500],
                                  insets, PlotRange -> 0, 1000, 0, 500]


                                  enter image description here






                                  share|improve this answer


























                                    up vote
                                    4
                                    down vote













                                    Small 10 x 5 version showing the first 50 digits of Pi



                                    colours = Transpose@Reverse@Partition[Characters[
                                    "3" <> StringDrop[ToString[N[Pi, 50]], 2]], 10];
                                    insets = Table[Inset[Style[Text[colours[[i + 1, j + 1]]],
                                    Black, FontSize -> 20],
                                    10 i, 10 j, 0, 0, 10, 10], i, 0, 10 - 1, j, 0, 5 - 1];
                                    Graphics[Yellow, Rectangle[0, 0, 100, 50], insets]


                                    Same again with colours



                                    colours = Transpose@Reverse@Partition[Characters[
                                    "3" <> StringDrop[ToString[N[Pi, 50]], 2]] /. Thread[
                                    ToString /@ Range[0, 9] -> ColorData[3, "ColorList"]], 10];
                                    insets = Table[Inset[Graphics[colours[[i + 1, j + 1]],
                                    Rectangle[0, 0, 10, 10],
                                    PlotRange -> 0, 10, 0, 10, ImageSize -> 10],
                                    10 i, 10 j, 0, 0, 10, 10], i, 0, 10 - 1, j, 0, 5 - 1];
                                    Graphics[Yellow, Rectangle[0, 0, 100, 50],
                                    insets, PlotRange -> 0, 100, 0, 50]


                                    Similar version showing the first 5000 characters of Pi



                                    colours = Transpose@Reverse@Partition[Characters[
                                    "3" <> StringDrop[ToString[N[Pi, 5000]], 2]] /. Thread[
                                    ToString /@ Range[0, 9] -> ColorData[3, "ColorList"]], 100];
                                    insets = Table[Inset[Graphics[colours[[i + 1, j + 1]],
                                    Rectangle[0, 0, 10, 10],
                                    PlotRange -> 0, 10, 0, 10, ImageSize -> 10],
                                    10 i, 10 j, 0, 0, 10, 10], i, 0, 100 - 1, j, 0, 50 - 1];
                                    Graphics[Yellow, Rectangle[0, 0, 1000, 500],
                                    insets, PlotRange -> 0, 1000, 0, 500]


                                    enter image description here






                                    share|improve this answer
























                                      up vote
                                      4
                                      down vote










                                      up vote
                                      4
                                      down vote









                                      Small 10 x 5 version showing the first 50 digits of Pi



                                      colours = Transpose@Reverse@Partition[Characters[
                                      "3" <> StringDrop[ToString[N[Pi, 50]], 2]], 10];
                                      insets = Table[Inset[Style[Text[colours[[i + 1, j + 1]]],
                                      Black, FontSize -> 20],
                                      10 i, 10 j, 0, 0, 10, 10], i, 0, 10 - 1, j, 0, 5 - 1];
                                      Graphics[Yellow, Rectangle[0, 0, 100, 50], insets]


                                      Same again with colours



                                      colours = Transpose@Reverse@Partition[Characters[
                                      "3" <> StringDrop[ToString[N[Pi, 50]], 2]] /. Thread[
                                      ToString /@ Range[0, 9] -> ColorData[3, "ColorList"]], 10];
                                      insets = Table[Inset[Graphics[colours[[i + 1, j + 1]],
                                      Rectangle[0, 0, 10, 10],
                                      PlotRange -> 0, 10, 0, 10, ImageSize -> 10],
                                      10 i, 10 j, 0, 0, 10, 10], i, 0, 10 - 1, j, 0, 5 - 1];
                                      Graphics[Yellow, Rectangle[0, 0, 100, 50],
                                      insets, PlotRange -> 0, 100, 0, 50]


                                      Similar version showing the first 5000 characters of Pi



                                      colours = Transpose@Reverse@Partition[Characters[
                                      "3" <> StringDrop[ToString[N[Pi, 5000]], 2]] /. Thread[
                                      ToString /@ Range[0, 9] -> ColorData[3, "ColorList"]], 100];
                                      insets = Table[Inset[Graphics[colours[[i + 1, j + 1]],
                                      Rectangle[0, 0, 10, 10],
                                      PlotRange -> 0, 10, 0, 10, ImageSize -> 10],
                                      10 i, 10 j, 0, 0, 10, 10], i, 0, 100 - 1, j, 0, 50 - 1];
                                      Graphics[Yellow, Rectangle[0, 0, 1000, 500],
                                      insets, PlotRange -> 0, 1000, 0, 500]


                                      enter image description here






                                      share|improve this answer














                                      Small 10 x 5 version showing the first 50 digits of Pi



                                      colours = Transpose@Reverse@Partition[Characters[
                                      "3" <> StringDrop[ToString[N[Pi, 50]], 2]], 10];
                                      insets = Table[Inset[Style[Text[colours[[i + 1, j + 1]]],
                                      Black, FontSize -> 20],
                                      10 i, 10 j, 0, 0, 10, 10], i, 0, 10 - 1, j, 0, 5 - 1];
                                      Graphics[Yellow, Rectangle[0, 0, 100, 50], insets]


                                      Same again with colours



                                      colours = Transpose@Reverse@Partition[Characters[
                                      "3" <> StringDrop[ToString[N[Pi, 50]], 2]] /. Thread[
                                      ToString /@ Range[0, 9] -> ColorData[3, "ColorList"]], 10];
                                      insets = Table[Inset[Graphics[colours[[i + 1, j + 1]],
                                      Rectangle[0, 0, 10, 10],
                                      PlotRange -> 0, 10, 0, 10, ImageSize -> 10],
                                      10 i, 10 j, 0, 0, 10, 10], i, 0, 10 - 1, j, 0, 5 - 1];
                                      Graphics[Yellow, Rectangle[0, 0, 100, 50],
                                      insets, PlotRange -> 0, 100, 0, 50]


                                      Similar version showing the first 5000 characters of Pi



                                      colours = Transpose@Reverse@Partition[Characters[
                                      "3" <> StringDrop[ToString[N[Pi, 5000]], 2]] /. Thread[
                                      ToString /@ Range[0, 9] -> ColorData[3, "ColorList"]], 100];
                                      insets = Table[Inset[Graphics[colours[[i + 1, j + 1]],
                                      Rectangle[0, 0, 10, 10],
                                      PlotRange -> 0, 10, 0, 10, ImageSize -> 10],
                                      10 i, 10 j, 0, 0, 10, 10], i, 0, 100 - 1, j, 0, 50 - 1];
                                      Graphics[Yellow, Rectangle[0, 0, 1000, 500],
                                      insets, PlotRange -> 0, 1000, 0, 500]


                                      enter image description here







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Sep 5 at 19:40

























                                      answered Sep 5 at 19:32









                                      Chris Degnen

                                      21.4k23281




                                      21.4k23281




















                                          mhd.math is a new contributor. Be nice, and check out our Code of Conduct.









                                           

                                          draft saved


                                          draft discarded


















                                          mhd.math is a new contributor. Be nice, and check out our Code of Conduct.












                                          mhd.math is a new contributor. Be nice, and check out our Code of Conduct.











                                          mhd.math is a new contributor. Be nice, and check out our Code of Conduct.













                                           


                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function ()
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181293%2fhow-to-plot-an-integer-with-a-specific-color-for-each-digit%23new-answer', 'question_page');

                                          );

                                          Post as a guest













































































                                          Comments

                                          Popular posts from this blog

                                          What does second last employer means? [closed]

                                          List of Gilmore Girls characters

                                          Confectionery