14
$\begingroup$

From the documentation:

Plot[2 Sin[x], {x, 0, 10}, Frame -> True, FrameLabel -> {x, y}, 
 PlotLabel -> 2 Sin[x], LabelStyle -> Orange]

enter image description here

But then add a frame style:

Plot[2 Sin[x], {x, 0, 10}, Frame -> True, FrameLabel -> {x, y}, 
 PlotLabel -> 2 Sin[x], FrameStyle -> Green, LabelStyle -> Orange]

enter image description here

To me this is unexpected. I thought FrameStyle controlled the frame style not the frame tick or frame label style (if explicit options had been entered for FrameTicksStyle and LabelStyle).

It is possible to separate the styles of the frame and the frame ticks (via FrameTicksStyle). I'm assuming I am missing something very obvious here but how can a user give separate the styles of the frame and the frame labels?

i.e. How can I create a plot with a blue frame and red frame labels?

(I know I can use Style when entering frame labels but I am seeking an answer in terms of plotting options -- if one exists.)

$\endgroup$
12
  • 1
    $\begingroup$ @J.M. ...and yet despite stating that both FrameTicksStyle and FrameStyle have a higher priority than LabelStyle, the explicit examples show that LabelStyle has a higher priority than FrameTicksStyle. I therefore wouldn't consider this part of the documentation to be enlightening :) $\endgroup$ Commented Jun 18, 2012 at 7:52
  • 1
    $\begingroup$ How are you defining higher priority? FrameTicksStyle supposed higher priority leaves labels unchanged whereas FrameStyle, also higher priority but it changes labels. If they are defined to have the same priority in relation to labels shouldn't they act the same? $\endgroup$ Commented Jun 18, 2012 at 7:59
  • 2
    $\begingroup$ Not pretty, but you can do something like Plot[2 Sin[x], {x, 0, 10}, Frame -> True, FrameLabel -> {x, y}, PlotLabel -> 2 Sin[x], FrameStyle -> Directive[Green, FontColor -> Orange], FrameTicksStyle -> Directive[FontColor -> Black], LabelStyle -> Orange] to have different styles for the frame labels, frame + ticks, and tick marks. $\endgroup$
    – Heike
    Commented Jun 18, 2012 at 8:49
  • 1
    $\begingroup$ @Heike can you put that in an answer? It may not be pretty but is still easier than wrapping Style around all frame labels. $\endgroup$ Commented Jun 18, 2012 at 8:52
  • 1
    $\begingroup$ @MikeHoneychurch I've added my comment as an answer $\endgroup$
    – Heike
    Commented Jun 18, 2012 at 9:35

2 Answers 2

15
$\begingroup$

As I mentioned in a comment, you can do something like this to have different styles for the frame, ticks, tick marks, plot label, and frame labels.

Plot[2 Sin[x], {x, 0, 10}, Frame -> True, FrameLabel -> {x, y}, 
 PlotLabel -> 2 Sin[x], 
 FrameStyle -> Directive[Green, FontColor -> Orange], 
 FrameTicksStyle -> Directive[Yellow, FontColor -> Black], 
 LabelStyle -> Purple]

Mathematica graphics

To style the text you can use other options as well such as FontSize, FontFamily, FontWeight etc., but the various options seem to inherit from each other, so setting for example FontSize -> 20 in LabelStyle will also set the size of the tick labels so you would need to set the FontSize in FrameTicksStyle to compensate.

Also, setting FontSize in LabelStyle doesn't seem influence the size of the PlotLabel. To change this you can use the BaseStyle option.

$\endgroup$
1
  • 2
    $\begingroup$ +1 I forgot the FontColor option sooo many times $\endgroup$ Commented Jun 18, 2012 at 13:02
4
$\begingroup$

"How can I create a plot with a blue frame and red frame labels?"

You could use BaseStyle instead of FrameStyle, however this also colours the x axis.

Plot[2 Sin[x], {x, 0, 10}, Frame -> True, FrameLabel -> {x, y}, 
 PlotLabel -> 2 Sin[x], BaseStyle -> Blue, LabelStyle -> Red]

enter image description here

$\endgroup$
1
  • $\begingroup$ This then raises other issues when you want to set frame thickness and so on. So it doesn't really address the more general separation of label and frame style. $\endgroup$ Commented Jun 18, 2012 at 11: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.