How to change the tick of the color bar legend to black
$begingroup$
Is there any option that allows one to change the ticks and borders of the bar legend in a density plot to black?
plotting
$endgroup$
add a comment |
$begingroup$
Is there any option that allows one to change the ticks and borders of the bar legend in a density plot to black?
plotting
$endgroup$
add a comment |
$begingroup$
Is there any option that allows one to change the ticks and borders of the bar legend in a density plot to black?
plotting
$endgroup$
Is there any option that allows one to change the ticks and borders of the bar legend in a density plot to black?
plotting
plotting
edited 7 hours ago
m_goldberg
89k873200
89k873200
asked 10 hours ago
bakerbaker
312
312
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
You can use PlotLegends -> BarLegend[Automatic, FrameStyle->Black]
instead of Automatic
to color the frame (although as CE notes, the FrameStyle
option will be colored red):
DensityPlot[
Sin[x] Sin[y], {x,-4,4}, {y,-3,3},
ColorFunction->"SunsetColors",
FrameStyle->Black,
PlotLegends->BarLegend[Automatic, FrameStyle->Black]
]
$endgroup$
add a comment |
$begingroup$
I don't see a way to style (Carl has shown how to provide the settings I show below directly in BarLegend
from DensityPlot
but there are some potential workarounds.DensityPlot
.)
bar = BarLegend["Rainbow",
FrameStyle -> Red,
TicksStyle -> Darker@Green,
LabelStyle -> Blue];
Legended[
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}],
bar
]
The coloring of some of the options to BarLegend
indicate that they don't work but they do:
produces the bar seen above, even though FrameStyle
and TicksStyle
are colored red. It's just something to be aware, it may mean that Wolfram Research aren't committed to making this work in future versions of Mathematica.
Another way to get more control of the color bar is to draw it yourself. Here's an example:
bar = ParametricPlot[
{x, y}, {x, 0, 1}, {y, 0, 1},
Frame -> True,
FrameTicks -> {{None, All}, {None, None}},
FrameStyle -> Red,
FrameTicksStyle -> Darker@Green,
PlotRange -> {{0, 1}, {0, 1}},
ColorFunction -> (ColorData["Rainbow", #2] &),
AspectRatio -> 10
];
Legended[
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}],
bar
]
$endgroup$
$begingroup$
Thanks! It is a hack, but is should do the job!
$endgroup$
– baker
4 hours ago
add a comment |
$begingroup$
It is something of a hack, but you can steal the bar legend from ContourPlot
. Like so.
Make a contour plot and select and copy the vertical bar legend.
ContourPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ColorFunction -> "SunsetColors",
PlotLegends -> Automatic]
Assign the copied graphic to a variable.
Use the variable in your density plot.
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ColorFunction -> "SunsetColors",
FrameStyle -> Black,
PlotLegends -> bar]
$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
});
}
});
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%2f195652%2fhow-to-change-the-tick-of-the-color-bar-legend-to-black%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$
You can use PlotLegends -> BarLegend[Automatic, FrameStyle->Black]
instead of Automatic
to color the frame (although as CE notes, the FrameStyle
option will be colored red):
DensityPlot[
Sin[x] Sin[y], {x,-4,4}, {y,-3,3},
ColorFunction->"SunsetColors",
FrameStyle->Black,
PlotLegends->BarLegend[Automatic, FrameStyle->Black]
]
$endgroup$
add a comment |
$begingroup$
You can use PlotLegends -> BarLegend[Automatic, FrameStyle->Black]
instead of Automatic
to color the frame (although as CE notes, the FrameStyle
option will be colored red):
DensityPlot[
Sin[x] Sin[y], {x,-4,4}, {y,-3,3},
ColorFunction->"SunsetColors",
FrameStyle->Black,
PlotLegends->BarLegend[Automatic, FrameStyle->Black]
]
$endgroup$
add a comment |
$begingroup$
You can use PlotLegends -> BarLegend[Automatic, FrameStyle->Black]
instead of Automatic
to color the frame (although as CE notes, the FrameStyle
option will be colored red):
DensityPlot[
Sin[x] Sin[y], {x,-4,4}, {y,-3,3},
ColorFunction->"SunsetColors",
FrameStyle->Black,
PlotLegends->BarLegend[Automatic, FrameStyle->Black]
]
$endgroup$
You can use PlotLegends -> BarLegend[Automatic, FrameStyle->Black]
instead of Automatic
to color the frame (although as CE notes, the FrameStyle
option will be colored red):
DensityPlot[
Sin[x] Sin[y], {x,-4,4}, {y,-3,3},
ColorFunction->"SunsetColors",
FrameStyle->Black,
PlotLegends->BarLegend[Automatic, FrameStyle->Black]
]
answered 7 hours ago
Carl WollCarl Woll
74.8k3100195
74.8k3100195
add a comment |
add a comment |
$begingroup$
I don't see a way to style (Carl has shown how to provide the settings I show below directly in BarLegend
from DensityPlot
but there are some potential workarounds.DensityPlot
.)
bar = BarLegend["Rainbow",
FrameStyle -> Red,
TicksStyle -> Darker@Green,
LabelStyle -> Blue];
Legended[
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}],
bar
]
The coloring of some of the options to BarLegend
indicate that they don't work but they do:
produces the bar seen above, even though FrameStyle
and TicksStyle
are colored red. It's just something to be aware, it may mean that Wolfram Research aren't committed to making this work in future versions of Mathematica.
Another way to get more control of the color bar is to draw it yourself. Here's an example:
bar = ParametricPlot[
{x, y}, {x, 0, 1}, {y, 0, 1},
Frame -> True,
FrameTicks -> {{None, All}, {None, None}},
FrameStyle -> Red,
FrameTicksStyle -> Darker@Green,
PlotRange -> {{0, 1}, {0, 1}},
ColorFunction -> (ColorData["Rainbow", #2] &),
AspectRatio -> 10
];
Legended[
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}],
bar
]
$endgroup$
$begingroup$
Thanks! It is a hack, but is should do the job!
$endgroup$
– baker
4 hours ago
add a comment |
$begingroup$
I don't see a way to style (Carl has shown how to provide the settings I show below directly in BarLegend
from DensityPlot
but there are some potential workarounds.DensityPlot
.)
bar = BarLegend["Rainbow",
FrameStyle -> Red,
TicksStyle -> Darker@Green,
LabelStyle -> Blue];
Legended[
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}],
bar
]
The coloring of some of the options to BarLegend
indicate that they don't work but they do:
produces the bar seen above, even though FrameStyle
and TicksStyle
are colored red. It's just something to be aware, it may mean that Wolfram Research aren't committed to making this work in future versions of Mathematica.
Another way to get more control of the color bar is to draw it yourself. Here's an example:
bar = ParametricPlot[
{x, y}, {x, 0, 1}, {y, 0, 1},
Frame -> True,
FrameTicks -> {{None, All}, {None, None}},
FrameStyle -> Red,
FrameTicksStyle -> Darker@Green,
PlotRange -> {{0, 1}, {0, 1}},
ColorFunction -> (ColorData["Rainbow", #2] &),
AspectRatio -> 10
];
Legended[
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}],
bar
]
$endgroup$
$begingroup$
Thanks! It is a hack, but is should do the job!
$endgroup$
– baker
4 hours ago
add a comment |
$begingroup$
I don't see a way to style (Carl has shown how to provide the settings I show below directly in BarLegend
from DensityPlot
but there are some potential workarounds.DensityPlot
.)
bar = BarLegend["Rainbow",
FrameStyle -> Red,
TicksStyle -> Darker@Green,
LabelStyle -> Blue];
Legended[
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}],
bar
]
The coloring of some of the options to BarLegend
indicate that they don't work but they do:
produces the bar seen above, even though FrameStyle
and TicksStyle
are colored red. It's just something to be aware, it may mean that Wolfram Research aren't committed to making this work in future versions of Mathematica.
Another way to get more control of the color bar is to draw it yourself. Here's an example:
bar = ParametricPlot[
{x, y}, {x, 0, 1}, {y, 0, 1},
Frame -> True,
FrameTicks -> {{None, All}, {None, None}},
FrameStyle -> Red,
FrameTicksStyle -> Darker@Green,
PlotRange -> {{0, 1}, {0, 1}},
ColorFunction -> (ColorData["Rainbow", #2] &),
AspectRatio -> 10
];
Legended[
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}],
bar
]
$endgroup$
I don't see a way to style (Carl has shown how to provide the settings I show below directly in BarLegend
from DensityPlot
but there are some potential workarounds.DensityPlot
.)
bar = BarLegend["Rainbow",
FrameStyle -> Red,
TicksStyle -> Darker@Green,
LabelStyle -> Blue];
Legended[
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}],
bar
]
The coloring of some of the options to BarLegend
indicate that they don't work but they do:
produces the bar seen above, even though FrameStyle
and TicksStyle
are colored red. It's just something to be aware, it may mean that Wolfram Research aren't committed to making this work in future versions of Mathematica.
Another way to get more control of the color bar is to draw it yourself. Here's an example:
bar = ParametricPlot[
{x, y}, {x, 0, 1}, {y, 0, 1},
Frame -> True,
FrameTicks -> {{None, All}, {None, None}},
FrameStyle -> Red,
FrameTicksStyle -> Darker@Green,
PlotRange -> {{0, 1}, {0, 1}},
ColorFunction -> (ColorData["Rainbow", #2] &),
AspectRatio -> 10
];
Legended[
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}],
bar
]
edited 5 hours ago
answered 7 hours ago
C. E.C. E.
51.3k3101207
51.3k3101207
$begingroup$
Thanks! It is a hack, but is should do the job!
$endgroup$
– baker
4 hours ago
add a comment |
$begingroup$
Thanks! It is a hack, but is should do the job!
$endgroup$
– baker
4 hours ago
$begingroup$
Thanks! It is a hack, but is should do the job!
$endgroup$
– baker
4 hours ago
$begingroup$
Thanks! It is a hack, but is should do the job!
$endgroup$
– baker
4 hours ago
add a comment |
$begingroup$
It is something of a hack, but you can steal the bar legend from ContourPlot
. Like so.
Make a contour plot and select and copy the vertical bar legend.
ContourPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ColorFunction -> "SunsetColors",
PlotLegends -> Automatic]
Assign the copied graphic to a variable.
Use the variable in your density plot.
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ColorFunction -> "SunsetColors",
FrameStyle -> Black,
PlotLegends -> bar]
$endgroup$
add a comment |
$begingroup$
It is something of a hack, but you can steal the bar legend from ContourPlot
. Like so.
Make a contour plot and select and copy the vertical bar legend.
ContourPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ColorFunction -> "SunsetColors",
PlotLegends -> Automatic]
Assign the copied graphic to a variable.
Use the variable in your density plot.
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ColorFunction -> "SunsetColors",
FrameStyle -> Black,
PlotLegends -> bar]
$endgroup$
add a comment |
$begingroup$
It is something of a hack, but you can steal the bar legend from ContourPlot
. Like so.
Make a contour plot and select and copy the vertical bar legend.
ContourPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ColorFunction -> "SunsetColors",
PlotLegends -> Automatic]
Assign the copied graphic to a variable.
Use the variable in your density plot.
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ColorFunction -> "SunsetColors",
FrameStyle -> Black,
PlotLegends -> bar]
$endgroup$
It is something of a hack, but you can steal the bar legend from ContourPlot
. Like so.
Make a contour plot and select and copy the vertical bar legend.
ContourPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ColorFunction -> "SunsetColors",
PlotLegends -> Automatic]
Assign the copied graphic to a variable.
Use the variable in your density plot.
DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
ColorFunction -> "SunsetColors",
FrameStyle -> Black,
PlotLegends -> bar]
answered 6 hours ago
m_goldbergm_goldberg
89k873200
89k873200
add a comment |
add a comment |
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%2f195652%2fhow-to-change-the-tick-of-the-color-bar-legend-to-black%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