How can I replace division sign with slash in ticks of BarLegend
$begingroup$
I am plotting a Bar legend for the density plot using BarLegend
. I got the desired bar legend but it has ticks in the form $frac{pi}{6},~frac{pi}{3},..$, I want them to be like $pi/6,~pi/3,...$ I want to write the division using slash. How can I do this in mathematica.
The code I am using is:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks -> {π/6, π/3, π/2, 2 π/3}]
plotting legending
New contributor
$endgroup$
add a comment |
$begingroup$
I am plotting a Bar legend for the density plot using BarLegend
. I got the desired bar legend but it has ticks in the form $frac{pi}{6},~frac{pi}{3},..$, I want them to be like $pi/6,~pi/3,...$ I want to write the division using slash. How can I do this in mathematica.
The code I am using is:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks -> {π/6, π/3, π/2, 2 π/3}]
plotting legending
New contributor
$endgroup$
3
$begingroup$
Hi Parveen, welcome to MMA.SE! Please consider adding some code to your question - it really helps us help you if we can quickly reproduce your results. I'm pretty sure you want something likeFormatType->StandardForm
!
$endgroup$
– Carl Lange
Jan 21 at 13:54
add a comment |
$begingroup$
I am plotting a Bar legend for the density plot using BarLegend
. I got the desired bar legend but it has ticks in the form $frac{pi}{6},~frac{pi}{3},..$, I want them to be like $pi/6,~pi/3,...$ I want to write the division using slash. How can I do this in mathematica.
The code I am using is:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks -> {π/6, π/3, π/2, 2 π/3}]
plotting legending
New contributor
$endgroup$
I am plotting a Bar legend for the density plot using BarLegend
. I got the desired bar legend but it has ticks in the form $frac{pi}{6},~frac{pi}{3},..$, I want them to be like $pi/6,~pi/3,...$ I want to write the division using slash. How can I do this in mathematica.
The code I am using is:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks -> {π/6, π/3, π/2, 2 π/3}]
plotting legending
plotting legending
New contributor
New contributor
edited Jan 21 at 16:03
Henrik Schumacher
51.2k469146
51.2k469146
New contributor
asked Jan 21 at 13:18
ParveenParveen
355
355
New contributor
New contributor
3
$begingroup$
Hi Parveen, welcome to MMA.SE! Please consider adding some code to your question - it really helps us help you if we can quickly reproduce your results. I'm pretty sure you want something likeFormatType->StandardForm
!
$endgroup$
– Carl Lange
Jan 21 at 13:54
add a comment |
3
$begingroup$
Hi Parveen, welcome to MMA.SE! Please consider adding some code to your question - it really helps us help you if we can quickly reproduce your results. I'm pretty sure you want something likeFormatType->StandardForm
!
$endgroup$
– Carl Lange
Jan 21 at 13:54
3
3
$begingroup$
Hi Parveen, welcome to MMA.SE! Please consider adding some code to your question - it really helps us help you if we can quickly reproduce your results. I'm pretty sure you want something like
FormatType->StandardForm
!$endgroup$
– Carl Lange
Jan 21 at 13:54
$begingroup$
Hi Parveen, welcome to MMA.SE! Please consider adding some code to your question - it really helps us help you if we can quickly reproduce your results. I'm pretty sure you want something like
FormatType->StandardForm
!$endgroup$
– Carl Lange
Jan 21 at 13:54
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
ticks = {π/6, π/3, π/2, 2 π/3};
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
"Ticks" -> Transpose[{#, # /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]} &@
ticks}],
LegendMarkerSize -> {30, 300}]
Alternatively, add the option "TickLabels"
:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False, "Ticks" -> ticks,
"TickLabels" -> (ticks /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]),
LegendMarkerSize -> {30, 300}]
$endgroup$
$begingroup$
Thanks for the answer. Something strange happened. I did copy and paste your code into my mathematica 11 and the ticks got interchanged. However I got the plot as you got but in my case $pi/6$ appears instead of $pi/2$. I don't know why!
$endgroup$
– Parveen
Jan 21 at 14:51
$begingroup$
@Parveen, it could be related to version/os. I am using version 11.3 (windows 10).
$endgroup$
– kglr
Jan 21 at 14:57
$begingroup$
Seems so. I am using ubuntu and mathematica 11
$endgroup$
– Parveen
Jan 21 at 15:00
$begingroup$
@Parveen, mathematica 11.3 or an earlier version?
$endgroup$
– kglr
Jan 21 at 15:01
$begingroup$
11.1.0.0 version
$endgroup$
– Parveen
Jan 21 at 15:02
|
show 4 more comments
$begingroup$
Something like this will work:
BarLegend[{
Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {[Pi]/6 - .1, 2 [Pi]/3 + .1}
},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks -> ({#, InputForm@#} & /@ {[Pi]/6, [Pi]/3, [Pi]/2,
2 [Pi]/3})]
The idea is to pass a list like {{x1,label1},{x2,label2}...}
to Ticks
.
Since it seems like you know exactly what you want to put into your ticks, you could just put strings:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {[Pi]/6 - .1,
2 [Pi]/3 + .1}},
LabelStyle ->
Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks ->
Transpose[{{[Pi]/6, [Pi]/3, [Pi]/2, 2 [Pi]/3}, {"[Pi]/6",
"[Pi]/3", "[Pi]/2", "2[Pi]/3"}}]]
$endgroup$
$begingroup$
Seems correct but I want $pi$ instead of $Pi$ and the upper most tick should be $2pi/3$ instead of $2*Pi/3$. If you can modify it, then it would be a great help
$endgroup$
– Parveen
Jan 21 at 14:53
$begingroup$
@Parveen Check my latest edit.
$endgroup$
– Carl Lange
Jan 21 at 15:10
$begingroup$
Thanks. It works now
$endgroup$
– Parveen
Jan 21 at 15:12
$begingroup$
Consider marking the answer (or @kglr's answer, which is at least as good as mine) as accepted if it solved your problem!
$endgroup$
– Carl Lange
Jan 21 at 15:22
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
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
});
}
});
Parveen 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%2f189940%2fhow-can-i-replace-division-sign-with-slash-in-ticks-of-barlegend%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
$begingroup$
ticks = {π/6, π/3, π/2, 2 π/3};
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
"Ticks" -> Transpose[{#, # /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]} &@
ticks}],
LegendMarkerSize -> {30, 300}]
Alternatively, add the option "TickLabels"
:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False, "Ticks" -> ticks,
"TickLabels" -> (ticks /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]),
LegendMarkerSize -> {30, 300}]
$endgroup$
$begingroup$
Thanks for the answer. Something strange happened. I did copy and paste your code into my mathematica 11 and the ticks got interchanged. However I got the plot as you got but in my case $pi/6$ appears instead of $pi/2$. I don't know why!
$endgroup$
– Parveen
Jan 21 at 14:51
$begingroup$
@Parveen, it could be related to version/os. I am using version 11.3 (windows 10).
$endgroup$
– kglr
Jan 21 at 14:57
$begingroup$
Seems so. I am using ubuntu and mathematica 11
$endgroup$
– Parveen
Jan 21 at 15:00
$begingroup$
@Parveen, mathematica 11.3 or an earlier version?
$endgroup$
– kglr
Jan 21 at 15:01
$begingroup$
11.1.0.0 version
$endgroup$
– Parveen
Jan 21 at 15:02
|
show 4 more comments
$begingroup$
ticks = {π/6, π/3, π/2, 2 π/3};
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
"Ticks" -> Transpose[{#, # /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]} &@
ticks}],
LegendMarkerSize -> {30, 300}]
Alternatively, add the option "TickLabels"
:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False, "Ticks" -> ticks,
"TickLabels" -> (ticks /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]),
LegendMarkerSize -> {30, 300}]
$endgroup$
$begingroup$
Thanks for the answer. Something strange happened. I did copy and paste your code into my mathematica 11 and the ticks got interchanged. However I got the plot as you got but in my case $pi/6$ appears instead of $pi/2$. I don't know why!
$endgroup$
– Parveen
Jan 21 at 14:51
$begingroup$
@Parveen, it could be related to version/os. I am using version 11.3 (windows 10).
$endgroup$
– kglr
Jan 21 at 14:57
$begingroup$
Seems so. I am using ubuntu and mathematica 11
$endgroup$
– Parveen
Jan 21 at 15:00
$begingroup$
@Parveen, mathematica 11.3 or an earlier version?
$endgroup$
– kglr
Jan 21 at 15:01
$begingroup$
11.1.0.0 version
$endgroup$
– Parveen
Jan 21 at 15:02
|
show 4 more comments
$begingroup$
ticks = {π/6, π/3, π/2, 2 π/3};
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
"Ticks" -> Transpose[{#, # /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]} &@
ticks}],
LegendMarkerSize -> {30, 300}]
Alternatively, add the option "TickLabels"
:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False, "Ticks" -> ticks,
"TickLabels" -> (ticks /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]),
LegendMarkerSize -> {30, 300}]
$endgroup$
ticks = {π/6, π/3, π/2, 2 π/3};
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
"Ticks" -> Transpose[{#, # /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]} &@
ticks}],
LegendMarkerSize -> {30, 300}]
Alternatively, add the option "TickLabels"
:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {π/6 - .1, 2 π/3 + .1}},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False, "Ticks" -> ticks,
"TickLabels" -> (ticks /. Times[Rational[a_, b_], Pi] :> Row[{a Pi, "/", b}]),
LegendMarkerSize -> {30, 300}]
edited Jan 21 at 15:07
answered Jan 21 at 14:42
kglrkglr
181k9200413
181k9200413
$begingroup$
Thanks for the answer. Something strange happened. I did copy and paste your code into my mathematica 11 and the ticks got interchanged. However I got the plot as you got but in my case $pi/6$ appears instead of $pi/2$. I don't know why!
$endgroup$
– Parveen
Jan 21 at 14:51
$begingroup$
@Parveen, it could be related to version/os. I am using version 11.3 (windows 10).
$endgroup$
– kglr
Jan 21 at 14:57
$begingroup$
Seems so. I am using ubuntu and mathematica 11
$endgroup$
– Parveen
Jan 21 at 15:00
$begingroup$
@Parveen, mathematica 11.3 or an earlier version?
$endgroup$
– kglr
Jan 21 at 15:01
$begingroup$
11.1.0.0 version
$endgroup$
– Parveen
Jan 21 at 15:02
|
show 4 more comments
$begingroup$
Thanks for the answer. Something strange happened. I did copy and paste your code into my mathematica 11 and the ticks got interchanged. However I got the plot as you got but in my case $pi/6$ appears instead of $pi/2$. I don't know why!
$endgroup$
– Parveen
Jan 21 at 14:51
$begingroup$
@Parveen, it could be related to version/os. I am using version 11.3 (windows 10).
$endgroup$
– kglr
Jan 21 at 14:57
$begingroup$
Seems so. I am using ubuntu and mathematica 11
$endgroup$
– Parveen
Jan 21 at 15:00
$begingroup$
@Parveen, mathematica 11.3 or an earlier version?
$endgroup$
– kglr
Jan 21 at 15:01
$begingroup$
11.1.0.0 version
$endgroup$
– Parveen
Jan 21 at 15:02
$begingroup$
Thanks for the answer. Something strange happened. I did copy and paste your code into my mathematica 11 and the ticks got interchanged. However I got the plot as you got but in my case $pi/6$ appears instead of $pi/2$. I don't know why!
$endgroup$
– Parveen
Jan 21 at 14:51
$begingroup$
Thanks for the answer. Something strange happened. I did copy and paste your code into my mathematica 11 and the ticks got interchanged. However I got the plot as you got but in my case $pi/6$ appears instead of $pi/2$. I don't know why!
$endgroup$
– Parveen
Jan 21 at 14:51
$begingroup$
@Parveen, it could be related to version/os. I am using version 11.3 (windows 10).
$endgroup$
– kglr
Jan 21 at 14:57
$begingroup$
@Parveen, it could be related to version/os. I am using version 11.3 (windows 10).
$endgroup$
– kglr
Jan 21 at 14:57
$begingroup$
Seems so. I am using ubuntu and mathematica 11
$endgroup$
– Parveen
Jan 21 at 15:00
$begingroup$
Seems so. I am using ubuntu and mathematica 11
$endgroup$
– Parveen
Jan 21 at 15:00
$begingroup$
@Parveen, mathematica 11.3 or an earlier version?
$endgroup$
– kglr
Jan 21 at 15:01
$begingroup$
@Parveen, mathematica 11.3 or an earlier version?
$endgroup$
– kglr
Jan 21 at 15:01
$begingroup$
11.1.0.0 version
$endgroup$
– Parveen
Jan 21 at 15:02
$begingroup$
11.1.0.0 version
$endgroup$
– Parveen
Jan 21 at 15:02
|
show 4 more comments
$begingroup$
Something like this will work:
BarLegend[{
Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {[Pi]/6 - .1, 2 [Pi]/3 + .1}
},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks -> ({#, InputForm@#} & /@ {[Pi]/6, [Pi]/3, [Pi]/2,
2 [Pi]/3})]
The idea is to pass a list like {{x1,label1},{x2,label2}...}
to Ticks
.
Since it seems like you know exactly what you want to put into your ticks, you could just put strings:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {[Pi]/6 - .1,
2 [Pi]/3 + .1}},
LabelStyle ->
Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks ->
Transpose[{{[Pi]/6, [Pi]/3, [Pi]/2, 2 [Pi]/3}, {"[Pi]/6",
"[Pi]/3", "[Pi]/2", "2[Pi]/3"}}]]
$endgroup$
$begingroup$
Seems correct but I want $pi$ instead of $Pi$ and the upper most tick should be $2pi/3$ instead of $2*Pi/3$. If you can modify it, then it would be a great help
$endgroup$
– Parveen
Jan 21 at 14:53
$begingroup$
@Parveen Check my latest edit.
$endgroup$
– Carl Lange
Jan 21 at 15:10
$begingroup$
Thanks. It works now
$endgroup$
– Parveen
Jan 21 at 15:12
$begingroup$
Consider marking the answer (or @kglr's answer, which is at least as good as mine) as accepted if it solved your problem!
$endgroup$
– Carl Lange
Jan 21 at 15:22
add a comment |
$begingroup$
Something like this will work:
BarLegend[{
Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {[Pi]/6 - .1, 2 [Pi]/3 + .1}
},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks -> ({#, InputForm@#} & /@ {[Pi]/6, [Pi]/3, [Pi]/2,
2 [Pi]/3})]
The idea is to pass a list like {{x1,label1},{x2,label2}...}
to Ticks
.
Since it seems like you know exactly what you want to put into your ticks, you could just put strings:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {[Pi]/6 - .1,
2 [Pi]/3 + .1}},
LabelStyle ->
Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks ->
Transpose[{{[Pi]/6, [Pi]/3, [Pi]/2, 2 [Pi]/3}, {"[Pi]/6",
"[Pi]/3", "[Pi]/2", "2[Pi]/3"}}]]
$endgroup$
$begingroup$
Seems correct but I want $pi$ instead of $Pi$ and the upper most tick should be $2pi/3$ instead of $2*Pi/3$. If you can modify it, then it would be a great help
$endgroup$
– Parveen
Jan 21 at 14:53
$begingroup$
@Parveen Check my latest edit.
$endgroup$
– Carl Lange
Jan 21 at 15:10
$begingroup$
Thanks. It works now
$endgroup$
– Parveen
Jan 21 at 15:12
$begingroup$
Consider marking the answer (or @kglr's answer, which is at least as good as mine) as accepted if it solved your problem!
$endgroup$
– Carl Lange
Jan 21 at 15:22
add a comment |
$begingroup$
Something like this will work:
BarLegend[{
Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {[Pi]/6 - .1, 2 [Pi]/3 + .1}
},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks -> ({#, InputForm@#} & /@ {[Pi]/6, [Pi]/3, [Pi]/2,
2 [Pi]/3})]
The idea is to pass a list like {{x1,label1},{x2,label2}...}
to Ticks
.
Since it seems like you know exactly what you want to put into your ticks, you could just put strings:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {[Pi]/6 - .1,
2 [Pi]/3 + .1}},
LabelStyle ->
Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks ->
Transpose[{{[Pi]/6, [Pi]/3, [Pi]/2, 2 [Pi]/3}, {"[Pi]/6",
"[Pi]/3", "[Pi]/2", "2[Pi]/3"}}]]
$endgroup$
Something like this will work:
BarLegend[{
Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {[Pi]/6 - .1, 2 [Pi]/3 + .1}
},
LabelStyle -> Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks -> ({#, InputForm@#} & /@ {[Pi]/6, [Pi]/3, [Pi]/2,
2 [Pi]/3})]
The idea is to pass a list like {{x1,label1},{x2,label2}...}
to Ticks
.
Since it seems like you know exactly what you want to put into your ticks, you could just put strings:
BarLegend[{Hue[Rescale[#, {0, Pi}, {0, 1}]] &, {[Pi]/6 - .1,
2 [Pi]/3 + .1}},
LabelStyle ->
Directive[Black, Bold, Medium, FontFamily -> "Courier"],
ColorFunctionScaling -> False,
Ticks ->
Transpose[{{[Pi]/6, [Pi]/3, [Pi]/2, 2 [Pi]/3}, {"[Pi]/6",
"[Pi]/3", "[Pi]/2", "2[Pi]/3"}}]]
edited Jan 21 at 15:10
answered Jan 21 at 14:45
Carl LangeCarl Lange
3,3401731
3,3401731
$begingroup$
Seems correct but I want $pi$ instead of $Pi$ and the upper most tick should be $2pi/3$ instead of $2*Pi/3$. If you can modify it, then it would be a great help
$endgroup$
– Parveen
Jan 21 at 14:53
$begingroup$
@Parveen Check my latest edit.
$endgroup$
– Carl Lange
Jan 21 at 15:10
$begingroup$
Thanks. It works now
$endgroup$
– Parveen
Jan 21 at 15:12
$begingroup$
Consider marking the answer (or @kglr's answer, which is at least as good as mine) as accepted if it solved your problem!
$endgroup$
– Carl Lange
Jan 21 at 15:22
add a comment |
$begingroup$
Seems correct but I want $pi$ instead of $Pi$ and the upper most tick should be $2pi/3$ instead of $2*Pi/3$. If you can modify it, then it would be a great help
$endgroup$
– Parveen
Jan 21 at 14:53
$begingroup$
@Parveen Check my latest edit.
$endgroup$
– Carl Lange
Jan 21 at 15:10
$begingroup$
Thanks. It works now
$endgroup$
– Parveen
Jan 21 at 15:12
$begingroup$
Consider marking the answer (or @kglr's answer, which is at least as good as mine) as accepted if it solved your problem!
$endgroup$
– Carl Lange
Jan 21 at 15:22
$begingroup$
Seems correct but I want $pi$ instead of $Pi$ and the upper most tick should be $2pi/3$ instead of $2*Pi/3$. If you can modify it, then it would be a great help
$endgroup$
– Parveen
Jan 21 at 14:53
$begingroup$
Seems correct but I want $pi$ instead of $Pi$ and the upper most tick should be $2pi/3$ instead of $2*Pi/3$. If you can modify it, then it would be a great help
$endgroup$
– Parveen
Jan 21 at 14:53
$begingroup$
@Parveen Check my latest edit.
$endgroup$
– Carl Lange
Jan 21 at 15:10
$begingroup$
@Parveen Check my latest edit.
$endgroup$
– Carl Lange
Jan 21 at 15:10
$begingroup$
Thanks. It works now
$endgroup$
– Parveen
Jan 21 at 15:12
$begingroup$
Thanks. It works now
$endgroup$
– Parveen
Jan 21 at 15:12
$begingroup$
Consider marking the answer (or @kglr's answer, which is at least as good as mine) as accepted if it solved your problem!
$endgroup$
– Carl Lange
Jan 21 at 15:22
$begingroup$
Consider marking the answer (or @kglr's answer, which is at least as good as mine) as accepted if it solved your problem!
$endgroup$
– Carl Lange
Jan 21 at 15:22
add a comment |
Parveen is a new contributor. Be nice, and check out our Code of Conduct.
Parveen is a new contributor. Be nice, and check out our Code of Conduct.
Parveen is a new contributor. Be nice, and check out our Code of Conduct.
Parveen 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%2f189940%2fhow-can-i-replace-division-sign-with-slash-in-ticks-of-barlegend%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
3
$begingroup$
Hi Parveen, welcome to MMA.SE! Please consider adding some code to your question - it really helps us help you if we can quickly reproduce your results. I'm pretty sure you want something like
FormatType->StandardForm
!$endgroup$
– Carl Lange
Jan 21 at 13:54