Plotting with different color for a single curvePlotting piecewise function with distinct colors in each sectionSubset of edges with a different colorNeed 4D plot (3D + color for function)Question about plotting one function with different colorsWant a different color for each curve displayed with ShowHow to plot data with different colors (or symbols) depending on a conditionListPlot with different color optionsListPlot with different color options part IIPlotting: every point in different colorPlotting a function with different parameters sets

What is the difference between and Embedding Layer and an Autoencoder?

Alphabet completion rate

Is there vegetarian astronaut?

Does squid ink pasta bleed?

Inverse-quotes-quine

Safe to store SMTP password in wp-config.php?

Should my manager be aware of private LinkedIn approaches I receive? How to politely have this happen?

C-152 carb heat on before landing in hot weather?

How to extract the storage of a smart contract?

STM Microcontroller burns every time

Links to webpages in books

MH370 blackbox - is it still possible to retrieve data from it?

Animation advice please

Change the boot order with no option in UEFI settings

Why is Madam Hooch not a professor?

How to get cool night-vision without lame drawbacks?

How to split an equation over two lines?

Can you apprehend something instead of someone?

How well known and how commonly used was Huffman coding in 1979?

Can ADFS connect to other SSO services?

Do flight schools typically have dress codes or expectations?

How can I repair scratches on a painted French door?

Cascading Repair Costs following Blown Head Gasket on a 2004 Subaru Outback

Are Finite Automata Turing Complete?



Plotting with different color for a single curve


Plotting piecewise function with distinct colors in each sectionSubset of edges with a different colorNeed 4D plot (3D + color for function)Question about plotting one function with different colorsWant a different color for each curve displayed with ShowHow to plot data with different colors (or symbols) depending on a conditionListPlot with different color optionsListPlot with different color options part IIPlotting: every point in different colorPlotting a function with different parameters sets






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








3












$begingroup$


How to plot a function $f(x)=frac3(4+x)3(2-x)-16$ (say $x in [-15,15]$ ) with the condition that i want to give different color for each of the following cases



(i) when $fracx+43x+10>0$ and $fracx^2+8x+123x+10>0$



(ii) when $fracx+43x+10>0$ and $fracx^2+8x+123x+10<0$



(iii) when $fracx+43x+10<0$ and $fracx^2+8x+123x+10>0$










share|improve this question







New contributor



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






$endgroup$


















    3












    $begingroup$


    How to plot a function $f(x)=frac3(4+x)3(2-x)-16$ (say $x in [-15,15]$ ) with the condition that i want to give different color for each of the following cases



    (i) when $fracx+43x+10>0$ and $fracx^2+8x+123x+10>0$



    (ii) when $fracx+43x+10>0$ and $fracx^2+8x+123x+10<0$



    (iii) when $fracx+43x+10<0$ and $fracx^2+8x+123x+10>0$










    share|improve this question







    New contributor



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






    $endgroup$














      3












      3








      3





      $begingroup$


      How to plot a function $f(x)=frac3(4+x)3(2-x)-16$ (say $x in [-15,15]$ ) with the condition that i want to give different color for each of the following cases



      (i) when $fracx+43x+10>0$ and $fracx^2+8x+123x+10>0$



      (ii) when $fracx+43x+10>0$ and $fracx^2+8x+123x+10<0$



      (iii) when $fracx+43x+10<0$ and $fracx^2+8x+123x+10>0$










      share|improve this question







      New contributor



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






      $endgroup$




      How to plot a function $f(x)=frac3(4+x)3(2-x)-16$ (say $x in [-15,15]$ ) with the condition that i want to give different color for each of the following cases



      (i) when $fracx+43x+10>0$ and $fracx^2+8x+123x+10>0$



      (ii) when $fracx+43x+10>0$ and $fracx^2+8x+123x+10<0$



      (iii) when $fracx+43x+10<0$ and $fracx^2+8x+123x+10>0$







      plotting






      share|improve this question







      New contributor



      Wom 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







      New contributor



      Wom 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






      New contributor



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








      asked 8 hours ago









      WomWom

      162 bronze badges




      162 bronze badges




      New contributor



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




      New contributor




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






















          3 Answers
          3






          active

          oldest

          votes


















          3












          $begingroup$

          Admittedly, not very different from the naïve answer already posted, just avoided repeating the function definitions.



          f[x_] := (3 (x + 4))/(3 (2 - x) - 16);

          g[x_] := (x + 4)/(3 x + 10);

          h[x_] := (x^2 + 8 x + 12)/(3 x + 10);

          a[x_] := (g[x] > 0 && h[x] > 0);
          b[x_] := (g[x] > 0 && h[x] < 0);
          c[x_] := (g[x] < 0 && h[x] > 0);

          Plot[f[x] && a[x], f[x] && b[x], f[x] && c[x], x, -15, 15,
          PlotRange -> -3, 3, PlotStyle -> Thickness[.01], Frame -> True,
          Axes -> False]


          enter image description here






          share|improve this answer









          $endgroup$




















            3












            $begingroup$

            You could use the option ColorFunction with ColorFunctionScaling->False. First your conditions:



            cond1[x_] := (x+4)/(3x+10)>0 && (x^2+8x+12)/(3x+10)>0
            cond2[x_] := (x+4)/(3x+10)>0 && (x^2+8x+12)/(3x+10)<0
            cond3[x_] := (x+4)/(3x+10)<0 && (x^2+8x+12)/(3x+10)>0


            And your function:



            f[x_] := (3(4+x))/(3(2-x)-16)


            Then:



            Plot[f[x], x, -15, 15,
            PlotRange -> All, -3, 3,
            ColorFunctionScaling -> False,
            ColorFunction -> Function @ Piecewise[

            ColorData[97][1], cond1[#],
            ColorData[97][2], cond2[#],
            ColorData[97][3], cond3[#]
            ,
            ColorData[97][4]
            ]
            ]


            enter image description here






            share|improve this answer









            $endgroup$




















              1












              $begingroup$

              Naïve solution:



              f1[x_] /; And[(x + 4)/(3 x + 10) > 0, (x^2 + 8 x + 12)/(3 x + 10) > 0] := (3 (4 + x))/(3 (2 - x) - 16)
              f2[x_] /; And[(x + 4)/(3 x + 10) > 0, (x^2 + 8 x + 12)/(3 x + 10) < 0] := (3 (4 + x))/(3 (2 - x) - 16)
              f3[x_] /; And[(x + 4)/(3 x + 10) < 0, (x^2 + 8 x + 12)/(3 x + 10) > 0] := (3 (4 + x))/(3 (2 - x) - 16)

              Plot[f1[x], f2[x], f3[x], x, -15, 15, PlotRange -> All, -10, 10]


              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
                );



                );






                Wom 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%2f200790%2fplotting-with-different-color-for-a-single-curve%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                3












                $begingroup$

                Admittedly, not very different from the naïve answer already posted, just avoided repeating the function definitions.



                f[x_] := (3 (x + 4))/(3 (2 - x) - 16);

                g[x_] := (x + 4)/(3 x + 10);

                h[x_] := (x^2 + 8 x + 12)/(3 x + 10);

                a[x_] := (g[x] > 0 && h[x] > 0);
                b[x_] := (g[x] > 0 && h[x] < 0);
                c[x_] := (g[x] < 0 && h[x] > 0);

                Plot[f[x] && a[x], f[x] && b[x], f[x] && c[x], x, -15, 15,
                PlotRange -> -3, 3, PlotStyle -> Thickness[.01], Frame -> True,
                Axes -> False]


                enter image description here






                share|improve this answer









                $endgroup$

















                  3












                  $begingroup$

                  Admittedly, not very different from the naïve answer already posted, just avoided repeating the function definitions.



                  f[x_] := (3 (x + 4))/(3 (2 - x) - 16);

                  g[x_] := (x + 4)/(3 x + 10);

                  h[x_] := (x^2 + 8 x + 12)/(3 x + 10);

                  a[x_] := (g[x] > 0 && h[x] > 0);
                  b[x_] := (g[x] > 0 && h[x] < 0);
                  c[x_] := (g[x] < 0 && h[x] > 0);

                  Plot[f[x] && a[x], f[x] && b[x], f[x] && c[x], x, -15, 15,
                  PlotRange -> -3, 3, PlotStyle -> Thickness[.01], Frame -> True,
                  Axes -> False]


                  enter image description here






                  share|improve this answer









                  $endgroup$















                    3












                    3








                    3





                    $begingroup$

                    Admittedly, not very different from the naïve answer already posted, just avoided repeating the function definitions.



                    f[x_] := (3 (x + 4))/(3 (2 - x) - 16);

                    g[x_] := (x + 4)/(3 x + 10);

                    h[x_] := (x^2 + 8 x + 12)/(3 x + 10);

                    a[x_] := (g[x] > 0 && h[x] > 0);
                    b[x_] := (g[x] > 0 && h[x] < 0);
                    c[x_] := (g[x] < 0 && h[x] > 0);

                    Plot[f[x] && a[x], f[x] && b[x], f[x] && c[x], x, -15, 15,
                    PlotRange -> -3, 3, PlotStyle -> Thickness[.01], Frame -> True,
                    Axes -> False]


                    enter image description here






                    share|improve this answer









                    $endgroup$



                    Admittedly, not very different from the naïve answer already posted, just avoided repeating the function definitions.



                    f[x_] := (3 (x + 4))/(3 (2 - x) - 16);

                    g[x_] := (x + 4)/(3 x + 10);

                    h[x_] := (x^2 + 8 x + 12)/(3 x + 10);

                    a[x_] := (g[x] > 0 && h[x] > 0);
                    b[x_] := (g[x] > 0 && h[x] < 0);
                    c[x_] := (g[x] < 0 && h[x] > 0);

                    Plot[f[x] && a[x], f[x] && b[x], f[x] && c[x], x, -15, 15,
                    PlotRange -> -3, 3, PlotStyle -> Thickness[.01], Frame -> True,
                    Axes -> False]


                    enter image description here







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 8 hours ago









                    mjwmjw

                    1,37510 bronze badges




                    1,37510 bronze badges























                        3












                        $begingroup$

                        You could use the option ColorFunction with ColorFunctionScaling->False. First your conditions:



                        cond1[x_] := (x+4)/(3x+10)>0 && (x^2+8x+12)/(3x+10)>0
                        cond2[x_] := (x+4)/(3x+10)>0 && (x^2+8x+12)/(3x+10)<0
                        cond3[x_] := (x+4)/(3x+10)<0 && (x^2+8x+12)/(3x+10)>0


                        And your function:



                        f[x_] := (3(4+x))/(3(2-x)-16)


                        Then:



                        Plot[f[x], x, -15, 15,
                        PlotRange -> All, -3, 3,
                        ColorFunctionScaling -> False,
                        ColorFunction -> Function @ Piecewise[

                        ColorData[97][1], cond1[#],
                        ColorData[97][2], cond2[#],
                        ColorData[97][3], cond3[#]
                        ,
                        ColorData[97][4]
                        ]
                        ]


                        enter image description here






                        share|improve this answer









                        $endgroup$

















                          3












                          $begingroup$

                          You could use the option ColorFunction with ColorFunctionScaling->False. First your conditions:



                          cond1[x_] := (x+4)/(3x+10)>0 && (x^2+8x+12)/(3x+10)>0
                          cond2[x_] := (x+4)/(3x+10)>0 && (x^2+8x+12)/(3x+10)<0
                          cond3[x_] := (x+4)/(3x+10)<0 && (x^2+8x+12)/(3x+10)>0


                          And your function:



                          f[x_] := (3(4+x))/(3(2-x)-16)


                          Then:



                          Plot[f[x], x, -15, 15,
                          PlotRange -> All, -3, 3,
                          ColorFunctionScaling -> False,
                          ColorFunction -> Function @ Piecewise[

                          ColorData[97][1], cond1[#],
                          ColorData[97][2], cond2[#],
                          ColorData[97][3], cond3[#]
                          ,
                          ColorData[97][4]
                          ]
                          ]


                          enter image description here






                          share|improve this answer









                          $endgroup$















                            3












                            3








                            3





                            $begingroup$

                            You could use the option ColorFunction with ColorFunctionScaling->False. First your conditions:



                            cond1[x_] := (x+4)/(3x+10)>0 && (x^2+8x+12)/(3x+10)>0
                            cond2[x_] := (x+4)/(3x+10)>0 && (x^2+8x+12)/(3x+10)<0
                            cond3[x_] := (x+4)/(3x+10)<0 && (x^2+8x+12)/(3x+10)>0


                            And your function:



                            f[x_] := (3(4+x))/(3(2-x)-16)


                            Then:



                            Plot[f[x], x, -15, 15,
                            PlotRange -> All, -3, 3,
                            ColorFunctionScaling -> False,
                            ColorFunction -> Function @ Piecewise[

                            ColorData[97][1], cond1[#],
                            ColorData[97][2], cond2[#],
                            ColorData[97][3], cond3[#]
                            ,
                            ColorData[97][4]
                            ]
                            ]


                            enter image description here






                            share|improve this answer









                            $endgroup$



                            You could use the option ColorFunction with ColorFunctionScaling->False. First your conditions:



                            cond1[x_] := (x+4)/(3x+10)>0 && (x^2+8x+12)/(3x+10)>0
                            cond2[x_] := (x+4)/(3x+10)>0 && (x^2+8x+12)/(3x+10)<0
                            cond3[x_] := (x+4)/(3x+10)<0 && (x^2+8x+12)/(3x+10)>0


                            And your function:



                            f[x_] := (3(4+x))/(3(2-x)-16)


                            Then:



                            Plot[f[x], x, -15, 15,
                            PlotRange -> All, -3, 3,
                            ColorFunctionScaling -> False,
                            ColorFunction -> Function @ Piecewise[

                            ColorData[97][1], cond1[#],
                            ColorData[97][2], cond2[#],
                            ColorData[97][3], cond3[#]
                            ,
                            ColorData[97][4]
                            ]
                            ]


                            enter image description here







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 7 hours ago









                            Carl WollCarl Woll

                            85k3 gold badges109 silver badges220 bronze badges




                            85k3 gold badges109 silver badges220 bronze badges





















                                1












                                $begingroup$

                                Naïve solution:



                                f1[x_] /; And[(x + 4)/(3 x + 10) > 0, (x^2 + 8 x + 12)/(3 x + 10) > 0] := (3 (4 + x))/(3 (2 - x) - 16)
                                f2[x_] /; And[(x + 4)/(3 x + 10) > 0, (x^2 + 8 x + 12)/(3 x + 10) < 0] := (3 (4 + x))/(3 (2 - x) - 16)
                                f3[x_] /; And[(x + 4)/(3 x + 10) < 0, (x^2 + 8 x + 12)/(3 x + 10) > 0] := (3 (4 + x))/(3 (2 - x) - 16)

                                Plot[f1[x], f2[x], f3[x], x, -15, 15, PlotRange -> All, -10, 10]


                                enter image description here






                                share|improve this answer









                                $endgroup$

















                                  1












                                  $begingroup$

                                  Naïve solution:



                                  f1[x_] /; And[(x + 4)/(3 x + 10) > 0, (x^2 + 8 x + 12)/(3 x + 10) > 0] := (3 (4 + x))/(3 (2 - x) - 16)
                                  f2[x_] /; And[(x + 4)/(3 x + 10) > 0, (x^2 + 8 x + 12)/(3 x + 10) < 0] := (3 (4 + x))/(3 (2 - x) - 16)
                                  f3[x_] /; And[(x + 4)/(3 x + 10) < 0, (x^2 + 8 x + 12)/(3 x + 10) > 0] := (3 (4 + x))/(3 (2 - x) - 16)

                                  Plot[f1[x], f2[x], f3[x], x, -15, 15, PlotRange -> All, -10, 10]


                                  enter image description here






                                  share|improve this answer









                                  $endgroup$















                                    1












                                    1








                                    1





                                    $begingroup$

                                    Naïve solution:



                                    f1[x_] /; And[(x + 4)/(3 x + 10) > 0, (x^2 + 8 x + 12)/(3 x + 10) > 0] := (3 (4 + x))/(3 (2 - x) - 16)
                                    f2[x_] /; And[(x + 4)/(3 x + 10) > 0, (x^2 + 8 x + 12)/(3 x + 10) < 0] := (3 (4 + x))/(3 (2 - x) - 16)
                                    f3[x_] /; And[(x + 4)/(3 x + 10) < 0, (x^2 + 8 x + 12)/(3 x + 10) > 0] := (3 (4 + x))/(3 (2 - x) - 16)

                                    Plot[f1[x], f2[x], f3[x], x, -15, 15, PlotRange -> All, -10, 10]


                                    enter image description here






                                    share|improve this answer









                                    $endgroup$



                                    Naïve solution:



                                    f1[x_] /; And[(x + 4)/(3 x + 10) > 0, (x^2 + 8 x + 12)/(3 x + 10) > 0] := (3 (4 + x))/(3 (2 - x) - 16)
                                    f2[x_] /; And[(x + 4)/(3 x + 10) > 0, (x^2 + 8 x + 12)/(3 x + 10) < 0] := (3 (4 + x))/(3 (2 - x) - 16)
                                    f3[x_] /; And[(x + 4)/(3 x + 10) < 0, (x^2 + 8 x + 12)/(3 x + 10) > 0] := (3 (4 + x))/(3 (2 - x) - 16)

                                    Plot[f1[x], f2[x], f3[x], x, -15, 15, PlotRange -> All, -10, 10]


                                    enter image description here







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 8 hours ago









                                    AccidentalFourierTransformAccidentalFourierTransform

                                    5,6051 gold badge11 silver badges42 bronze badges




                                    5,6051 gold badge11 silver badges42 bronze badges




















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









                                        draft saved

                                        draft discarded


















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












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











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














                                        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%2f200790%2fplotting-with-different-color-for-a-single-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

                                        Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

                                        The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

                                        19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу