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;
$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$
plotting
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$
add a comment |
$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$
plotting
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$
add a comment |
$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$
plotting
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
plotting
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.
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.
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
$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]

$endgroup$
add a comment |
$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]
]
]

$endgroup$
add a comment |
$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]

$endgroup$
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
$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]

$endgroup$
add a comment |
$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]

$endgroup$
add a comment |
$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]

$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]

answered 8 hours ago
mjwmjw
1,37510 bronze badges
1,37510 bronze badges
add a comment |
add a comment |
$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]
]
]

$endgroup$
add a comment |
$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]
]
]

$endgroup$
add a comment |
$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]
]
]

$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]
]
]

answered 7 hours ago
Carl WollCarl Woll
85k3 gold badges109 silver badges220 bronze badges
85k3 gold badges109 silver badges220 bronze badges
add a comment |
add a comment |
$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]

$endgroup$
add a comment |
$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]

$endgroup$
add a comment |
$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]

$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]

answered 8 hours ago
AccidentalFourierTransformAccidentalFourierTransform
5,6051 gold badge11 silver badges42 bronze badges
5,6051 gold badge11 silver badges42 bronze badges
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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