1
$\begingroup$

Is it possible to set different colors for individual ticks? I have a few differently colored arrows and I'd like to show their coordinates in different colors. Here, the two ticks on the X-axis represent X coordinates of the green and red arrow, can I make them green and red respectively? Here, the two ticks on the X-axis represent X coordinates of the green and red arrow, can I make them green and red respectively?

$\endgroup$

1 Answer 1

3
$\begingroup$

Here is the documentation for Ticks:

enter image description here

So, here is a graphic with red and blue ticks, and green and orange tick labels:

Graphics[
    {},
    Axes->True,
    Ticks->{
        {{.2, Style["1",Green], {.02,.02}, Red}, {.8,Style["2",Orange],{.02,.02},Blue}},
        None
    }
]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks! Didn't know about the Style[] function. $\endgroup$
    – bqback
    Commented Sep 23, 2017 at 4:46
  • $\begingroup$ Is there a way to move labels to the opposite sides of the axes? E.g. move a label on Y-axis placed to the left of the axis to the right side. Some of my labels are overlapping with each other or the arrows. $\endgroup$
    – bqback
    Commented Sep 23, 2017 at 5:48
  • 1
    $\begingroup$ I don't think it's possible using the Ticks option without some major hackery. On the other hand, you could just use a Text primitive, e.g. Graphics[{Text["text", Offset[{0, 15}, {.1, 0}]]}, Axes -> True, Ticks -> {{{.1, ""}, {.5, "foo"}}, None}, PlotRange -> {{0, 1}, {0, 1}}] $\endgroup$
    – Carl Woll
    Commented Sep 23, 2017 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.