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 legal status of travelling with (unprescribed) methadone in your carry-on?

How to reply to small talk/random facts in a non-offensive way?

An expansion from Ramanujan related to birthday problem

How do I make a very short story impactful?

What happens when I sacrifice a creature when my Teysa Karlov is on the battlefield?

Why do some games show lights shine through walls?

Importance of the principal bundle in Chern-Simons theory

Is there a maximum distance from a planet that a moon can orbit?

Is it damaging to turn off a small fridge for two days every week?

Should I include salary information on my CV?

Can ADFS connect to other SSO services?

What are the benefits of using the X Card safety tool in comparison to plain communication?

Is adding a new player (or players) a DM decision, or a group decision?

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

Do equal angles necessarily mean a polygon is regular?

What do you call a weak person's act of taking on bigger opponents?

Why is Madam Hooch not a professor?

When is it ok to add filler to a story?

Distance Matrix (plugin) - QGIS

Can’t attend PhD conferences

Is there any set of 2-6 notes that doesn't have a chord name?

Why is my code printing rvalue 2 times instead of rvalue & lvalue?

Does squid ink pasta bleed?

Plotting with different color for a single curve



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

                                        Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                                        Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                                        François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480