Why does Plot only sometimes use different colors for each curvePlot draws list of curves in same color when...

Time war story - soldier name lengthens as he travels further from the battle front

How to split the polynomial .

I want light controlled by one switch, not two

Improving an O(N^2) function (all entities iterating over all other entities)

Ethiopian Airlines tickets seem to always have the same price regardless of the proximity of the date?

Router restarts after big git push or big file upload

Where can I find standards for statistical acronyms and whether they should be capitalized or lower case?

Manager is asking me to eat breakfast from now on

Do we have to introduce the character's name before using their names in a dialogue tag?

How to hook up Korg EX-8000 to a computer w/o a keyboard?

Satellite in orbit in front of and behind the Moon

How was Luke's prosthetic hand in Episode V filmed?

P-adic functions on annuli

Would using carbon dioxide as fuel work to reduce the greenhouse effect?

How can electronics on board JWST survive the low operating temperature while it's difficult to survive lunar nights?

3D cursor orientation

How far off did Apollo 11 land?

Date input format problem

A bicolour masyu

What's a German word for »Sandbagger«?

How can I create an article with a title like the 1960s Journal of Finance?

Find position equal columns of matrix

Three phase systems - are there any single phase devices that are connected between two phases instead of between one phase and neutral?

Conditional statement in a function for PS1 are not re-evalutated



Why does Plot only sometimes use different colors for each curve


Plot draws list of curves in same color when not using EvaluateUsing Evaluate and Evaluated -> True in PlotPlot graphs in different colorsUse different ColorFunction for each function plottedPlot sublists as different colorsPlot graphs in different colorsWhy does the replace all (/.) evaluate differently in plotWant a different color for each curve displayed with ShowHow to Color each curve differently?How to plot data sets each of different length?ErrorListPlot with a different color for each element of the listPlotting with different color for a single curveHow to Plot several functions using differents colors , It is possible to use TeX or MathSymbols?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2












$begingroup$


In this example Plot does not color each curve differently:



Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12}]


but in this example it does:



Plot[{vx0 Sin[t] /. {vy0 -> 1, vx0 -> 1}, 
vy0 Cos[t] /. {vy0 -> 1, vx0 -> 1}}, {t, 0, 12}]


How do I automatically enable Mathematica to give a different color to each curve?










share|improve this question









$endgroup$








  • 3




    $begingroup$
    Evaluate?${}$
    $endgroup$
    – AccidentalFourierTransform
    8 hours ago










  • $begingroup$
    Mathematica guesses how many curves there are before the plot expression is evaluated. In most cases, you can get the result you want by wrapping the expression with Evaluate
    $endgroup$
    – mikado
    8 hours ago










  • $begingroup$
    Evaluate works, is that the simplest solution? Why does it guess incorrectly in one case? It feels like excess coding just to plot two curves.
    $endgroup$
    – kotozna
    8 hours ago










  • $begingroup$
    Possible duplicate: mathematica.stackexchange.com/questions/1731/… and mathematica.stackexchange.com/questions/43323/…
    $endgroup$
    – Michael E2
    3 hours ago




















2












$begingroup$


In this example Plot does not color each curve differently:



Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12}]


but in this example it does:



Plot[{vx0 Sin[t] /. {vy0 -> 1, vx0 -> 1}, 
vy0 Cos[t] /. {vy0 -> 1, vx0 -> 1}}, {t, 0, 12}]


How do I automatically enable Mathematica to give a different color to each curve?










share|improve this question









$endgroup$








  • 3




    $begingroup$
    Evaluate?${}$
    $endgroup$
    – AccidentalFourierTransform
    8 hours ago










  • $begingroup$
    Mathematica guesses how many curves there are before the plot expression is evaluated. In most cases, you can get the result you want by wrapping the expression with Evaluate
    $endgroup$
    – mikado
    8 hours ago










  • $begingroup$
    Evaluate works, is that the simplest solution? Why does it guess incorrectly in one case? It feels like excess coding just to plot two curves.
    $endgroup$
    – kotozna
    8 hours ago










  • $begingroup$
    Possible duplicate: mathematica.stackexchange.com/questions/1731/… and mathematica.stackexchange.com/questions/43323/…
    $endgroup$
    – Michael E2
    3 hours ago
















2












2








2





$begingroup$


In this example Plot does not color each curve differently:



Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12}]


but in this example it does:



Plot[{vx0 Sin[t] /. {vy0 -> 1, vx0 -> 1}, 
vy0 Cos[t] /. {vy0 -> 1, vx0 -> 1}}, {t, 0, 12}]


How do I automatically enable Mathematica to give a different color to each curve?










share|improve this question









$endgroup$




In this example Plot does not color each curve differently:



Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12}]


but in this example it does:



Plot[{vx0 Sin[t] /. {vy0 -> 1, vx0 -> 1}, 
vy0 Cos[t] /. {vy0 -> 1, vx0 -> 1}}, {t, 0, 12}]


How do I automatically enable Mathematica to give a different color to each curve?







plotting






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









kotoznakotozna

1165 bronze badges




1165 bronze badges








  • 3




    $begingroup$
    Evaluate?${}$
    $endgroup$
    – AccidentalFourierTransform
    8 hours ago










  • $begingroup$
    Mathematica guesses how many curves there are before the plot expression is evaluated. In most cases, you can get the result you want by wrapping the expression with Evaluate
    $endgroup$
    – mikado
    8 hours ago










  • $begingroup$
    Evaluate works, is that the simplest solution? Why does it guess incorrectly in one case? It feels like excess coding just to plot two curves.
    $endgroup$
    – kotozna
    8 hours ago










  • $begingroup$
    Possible duplicate: mathematica.stackexchange.com/questions/1731/… and mathematica.stackexchange.com/questions/43323/…
    $endgroup$
    – Michael E2
    3 hours ago
















  • 3




    $begingroup$
    Evaluate?${}$
    $endgroup$
    – AccidentalFourierTransform
    8 hours ago










  • $begingroup$
    Mathematica guesses how many curves there are before the plot expression is evaluated. In most cases, you can get the result you want by wrapping the expression with Evaluate
    $endgroup$
    – mikado
    8 hours ago










  • $begingroup$
    Evaluate works, is that the simplest solution? Why does it guess incorrectly in one case? It feels like excess coding just to plot two curves.
    $endgroup$
    – kotozna
    8 hours ago










  • $begingroup$
    Possible duplicate: mathematica.stackexchange.com/questions/1731/… and mathematica.stackexchange.com/questions/43323/…
    $endgroup$
    – Michael E2
    3 hours ago










3




3




$begingroup$
Evaluate?${}$
$endgroup$
– AccidentalFourierTransform
8 hours ago




$begingroup$
Evaluate?${}$
$endgroup$
– AccidentalFourierTransform
8 hours ago












$begingroup$
Mathematica guesses how many curves there are before the plot expression is evaluated. In most cases, you can get the result you want by wrapping the expression with Evaluate
$endgroup$
– mikado
8 hours ago




$begingroup$
Mathematica guesses how many curves there are before the plot expression is evaluated. In most cases, you can get the result you want by wrapping the expression with Evaluate
$endgroup$
– mikado
8 hours ago












$begingroup$
Evaluate works, is that the simplest solution? Why does it guess incorrectly in one case? It feels like excess coding just to plot two curves.
$endgroup$
– kotozna
8 hours ago




$begingroup$
Evaluate works, is that the simplest solution? Why does it guess incorrectly in one case? It feels like excess coding just to plot two curves.
$endgroup$
– kotozna
8 hours ago












$begingroup$
Possible duplicate: mathematica.stackexchange.com/questions/1731/… and mathematica.stackexchange.com/questions/43323/…
$endgroup$
– Michael E2
3 hours ago






$begingroup$
Possible duplicate: mathematica.stackexchange.com/questions/1731/… and mathematica.stackexchange.com/questions/43323/…
$endgroup$
– Michael E2
3 hours ago












2 Answers
2






active

oldest

votes


















5












$begingroup$

Compare the FullForm of your two inputs:



FullForm[Hold[Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12}]]]
(*
Hold[Plot[ReplaceAll[List[Times[vx0,Sin[t]],Times[vy0,Cos[t]]],
List[Rule[vy0,1],Rule[vx0,1]]],List[t,0,12]]]
*)

FullForm[Hold[Plot[{vx0 Sin[t] /. {vy0 -> 1, vx0 -> 1}, vy0 Cos[t] /.
{vy0 -> 1, vx0 -> 1}}, {t, 0, 12}]]]
(*
Hold[Plot[List[ReplaceAll[Times[vx0,Sin[t]],List[Rule[vy0,1],Rule[vx0,1]]],
ReplaceAll[Times[vy0,Cos[t]],List[Rule[vy0,1],Rule[vx0,1]]]],List[t,0,12]]]
*)


For the second, the head of the first argument to Plot is List. When Plot sees this, it uses the length of the list as the number of colors to choose. For the first, the head is ReplaceAll. In this case, it doesn't anticipate that there will be more than one plot, so it only chooses one color.



Evaluate lets ReplaceAll do its job before Plot sees the argument. This yields a list, which allows plot to determine the number of colors to choose.






share|improve this answer











$endgroup$





















    1












    $begingroup$

    See




    • for an explanation of the general problem: Plot draws list of curves in same color when not using Evaluate

    • for this specific problem: Plot graphs in different colors

    • for the differences below: Using Evaluate and Evaluated -> True in Plot


    Note the difference if t has a value:



    t = 2.;

    Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12},
    Evaluated -> True]


    enter image description here



    Plot[Evaluate[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}], {t, 0, 12}]


    enter image description here






    share|improve this answer









    $endgroup$
















      Your Answer








      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%2f202511%2fwhy-does-plot-only-sometimes-use-different-colors-for-each-curve%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$

      Compare the FullForm of your two inputs:



      FullForm[Hold[Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12}]]]
      (*
      Hold[Plot[ReplaceAll[List[Times[vx0,Sin[t]],Times[vy0,Cos[t]]],
      List[Rule[vy0,1],Rule[vx0,1]]],List[t,0,12]]]
      *)

      FullForm[Hold[Plot[{vx0 Sin[t] /. {vy0 -> 1, vx0 -> 1}, vy0 Cos[t] /.
      {vy0 -> 1, vx0 -> 1}}, {t, 0, 12}]]]
      (*
      Hold[Plot[List[ReplaceAll[Times[vx0,Sin[t]],List[Rule[vy0,1],Rule[vx0,1]]],
      ReplaceAll[Times[vy0,Cos[t]],List[Rule[vy0,1],Rule[vx0,1]]]],List[t,0,12]]]
      *)


      For the second, the head of the first argument to Plot is List. When Plot sees this, it uses the length of the list as the number of colors to choose. For the first, the head is ReplaceAll. In this case, it doesn't anticipate that there will be more than one plot, so it only chooses one color.



      Evaluate lets ReplaceAll do its job before Plot sees the argument. This yields a list, which allows plot to determine the number of colors to choose.






      share|improve this answer











      $endgroup$


















        5












        $begingroup$

        Compare the FullForm of your two inputs:



        FullForm[Hold[Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12}]]]
        (*
        Hold[Plot[ReplaceAll[List[Times[vx0,Sin[t]],Times[vy0,Cos[t]]],
        List[Rule[vy0,1],Rule[vx0,1]]],List[t,0,12]]]
        *)

        FullForm[Hold[Plot[{vx0 Sin[t] /. {vy0 -> 1, vx0 -> 1}, vy0 Cos[t] /.
        {vy0 -> 1, vx0 -> 1}}, {t, 0, 12}]]]
        (*
        Hold[Plot[List[ReplaceAll[Times[vx0,Sin[t]],List[Rule[vy0,1],Rule[vx0,1]]],
        ReplaceAll[Times[vy0,Cos[t]],List[Rule[vy0,1],Rule[vx0,1]]]],List[t,0,12]]]
        *)


        For the second, the head of the first argument to Plot is List. When Plot sees this, it uses the length of the list as the number of colors to choose. For the first, the head is ReplaceAll. In this case, it doesn't anticipate that there will be more than one plot, so it only chooses one color.



        Evaluate lets ReplaceAll do its job before Plot sees the argument. This yields a list, which allows plot to determine the number of colors to choose.






        share|improve this answer











        $endgroup$
















          5












          5








          5





          $begingroup$

          Compare the FullForm of your two inputs:



          FullForm[Hold[Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12}]]]
          (*
          Hold[Plot[ReplaceAll[List[Times[vx0,Sin[t]],Times[vy0,Cos[t]]],
          List[Rule[vy0,1],Rule[vx0,1]]],List[t,0,12]]]
          *)

          FullForm[Hold[Plot[{vx0 Sin[t] /. {vy0 -> 1, vx0 -> 1}, vy0 Cos[t] /.
          {vy0 -> 1, vx0 -> 1}}, {t, 0, 12}]]]
          (*
          Hold[Plot[List[ReplaceAll[Times[vx0,Sin[t]],List[Rule[vy0,1],Rule[vx0,1]]],
          ReplaceAll[Times[vy0,Cos[t]],List[Rule[vy0,1],Rule[vx0,1]]]],List[t,0,12]]]
          *)


          For the second, the head of the first argument to Plot is List. When Plot sees this, it uses the length of the list as the number of colors to choose. For the first, the head is ReplaceAll. In this case, it doesn't anticipate that there will be more than one plot, so it only chooses one color.



          Evaluate lets ReplaceAll do its job before Plot sees the argument. This yields a list, which allows plot to determine the number of colors to choose.






          share|improve this answer











          $endgroup$



          Compare the FullForm of your two inputs:



          FullForm[Hold[Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12}]]]
          (*
          Hold[Plot[ReplaceAll[List[Times[vx0,Sin[t]],Times[vy0,Cos[t]]],
          List[Rule[vy0,1],Rule[vx0,1]]],List[t,0,12]]]
          *)

          FullForm[Hold[Plot[{vx0 Sin[t] /. {vy0 -> 1, vx0 -> 1}, vy0 Cos[t] /.
          {vy0 -> 1, vx0 -> 1}}, {t, 0, 12}]]]
          (*
          Hold[Plot[List[ReplaceAll[Times[vx0,Sin[t]],List[Rule[vy0,1],Rule[vx0,1]]],
          ReplaceAll[Times[vy0,Cos[t]],List[Rule[vy0,1],Rule[vx0,1]]]],List[t,0,12]]]
          *)


          For the second, the head of the first argument to Plot is List. When Plot sees this, it uses the length of the list as the number of colors to choose. For the first, the head is ReplaceAll. In this case, it doesn't anticipate that there will be more than one plot, so it only chooses one color.



          Evaluate lets ReplaceAll do its job before Plot sees the argument. This yields a list, which allows plot to determine the number of colors to choose.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 6 hours ago

























          answered 6 hours ago









          John DotyJohn Doty

          8,3481 gold badge12 silver badges24 bronze badges




          8,3481 gold badge12 silver badges24 bronze badges

























              1












              $begingroup$

              See




              • for an explanation of the general problem: Plot draws list of curves in same color when not using Evaluate

              • for this specific problem: Plot graphs in different colors

              • for the differences below: Using Evaluate and Evaluated -> True in Plot


              Note the difference if t has a value:



              t = 2.;

              Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12},
              Evaluated -> True]


              enter image description here



              Plot[Evaluate[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}], {t, 0, 12}]


              enter image description here






              share|improve this answer









              $endgroup$


















                1












                $begingroup$

                See




                • for an explanation of the general problem: Plot draws list of curves in same color when not using Evaluate

                • for this specific problem: Plot graphs in different colors

                • for the differences below: Using Evaluate and Evaluated -> True in Plot


                Note the difference if t has a value:



                t = 2.;

                Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12},
                Evaluated -> True]


                enter image description here



                Plot[Evaluate[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}], {t, 0, 12}]


                enter image description here






                share|improve this answer









                $endgroup$
















                  1












                  1








                  1





                  $begingroup$

                  See




                  • for an explanation of the general problem: Plot draws list of curves in same color when not using Evaluate

                  • for this specific problem: Plot graphs in different colors

                  • for the differences below: Using Evaluate and Evaluated -> True in Plot


                  Note the difference if t has a value:



                  t = 2.;

                  Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12},
                  Evaluated -> True]


                  enter image description here



                  Plot[Evaluate[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}], {t, 0, 12}]


                  enter image description here






                  share|improve this answer









                  $endgroup$



                  See




                  • for an explanation of the general problem: Plot draws list of curves in same color when not using Evaluate

                  • for this specific problem: Plot graphs in different colors

                  • for the differences below: Using Evaluate and Evaluated -> True in Plot


                  Note the difference if t has a value:



                  t = 2.;

                  Plot[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}, {t, 0, 12},
                  Evaluated -> True]


                  enter image description here



                  Plot[Evaluate[{vx0 Sin[t], vy0 Cos[t]} /. {vy0 -> 1, vx0 -> 1}], {t, 0, 12}]


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 3 hours ago









                  Michael E2Michael E2

                  156k13 gold badges214 silver badges506 bronze badges




                  156k13 gold badges214 silver badges506 bronze badges






























                      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%2f202511%2fwhy-does-plot-only-sometimes-use-different-colors-for-each-curve%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

                      Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                      Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                      Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...