4
$\begingroup$

I can set the Options for Plot as:

SetOptions[
  Plot, 
  AxesStyle -> 
 {{Black, 14, Italic, FontFamily -> "Times"}, 
 {Black, 14, Italic, FontFamily -> "Times"}}];

But it also changes the style on the labels themselves (which I want in a different style), e.g., "x" and "y" in this example:

Plot[Cos[x],
 {x, -5, 5},
 AxesLabel -> {"x", "y"}]

How can I set the Options for the added labels to be separate from the rest of the AxesStyle? As an example, suppose I want the "x" and "y" to be Red, Bold, and 28 points?

Of course I can hand code those styles each time into the AxesLabel specifications, but I'd like to do it with Options.

$\endgroup$
7
  • $\begingroup$ Add the options FontColor -> Red, FontWeight -> Bold when you set AxesStyle? $\endgroup$
    – kglr
    Commented Dec 19, 2019 at 2:41
  • $\begingroup$ @kglr: Nope. Doesn't work: It makes all the text red. And note that I want the size of the axes ticks to be different from the "x" and "y" labels too. $\endgroup$ Commented Dec 19, 2019 at 2:43
  • $\begingroup$ sorry; i see... $\endgroup$
    – kglr
    Commented Dec 19, 2019 at 2:45
  • $\begingroup$ maybe add the option TicksStyle -> FontColor -> Black to override the FontColor ->Red in set in AxesStyle? $\endgroup$
    – kglr
    Commented Dec 19, 2019 at 2:49
  • $\begingroup$ @kglr: You set me on the right track; override was the key. SetOptions[Plot, Sequence[ AxesStyle -> {{28, Italic, FontFamily -> "Times", FontColor -> Red}, {28, Italic, FontFamily -> "Times", FontColor -> Red}}], TicksStyle -> {{14, FontColor -> Black}, {14, FontColor -> Black}}]; Post that and I'll accept it. $\endgroup$ Commented Dec 19, 2019 at 2:53

1 Answer 1

4
$\begingroup$

You can override the font settings given in AxesStyle using TicksStyle:

SetOptions[Plot, 
  {AxesStyle -> Directive[28, Italic, FontFamily -> "Times", FontColor -> Red], 
   TicksStyle -> Directive[14, FontColor -> Black]}]

Plot[Sin[x], {x, 0, 2 Pi}, AxesLabel -> {"X", "Y"}]

enter image description here

$\endgroup$
1
  • 2
    $\begingroup$ I really do dislike how TicksStyle is misnamed... it's really more like TickLabelStyle. $\endgroup$
    – b3m2a1
    Commented Dec 19, 2019 at 8:32

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.