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?
1 Answer
Here is the documentation for Ticks
:
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
}
]
-
$\begingroup$ Thanks! Didn't know about the Style[] function. $\endgroup$– bqbackSep 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$– bqbackSep 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 aText
primitive, e.g.Graphics[{Text["text", Offset[{0, 15}, {.1, 0}]]}, Axes -> True, Ticks -> {{{.1, ""}, {.5, "foo"}}, None}, PlotRange -> {{0, 1}, {0, 1}}]
$\endgroup$ Sep 23, 2017 at 19:44