1

I'm trying to insert mathematical expressions into the titles of plots. I need to control the spacing within the mathematical expressions. For example, I'd like to show the expression "64/8 / 8" except with division signs instead of slashes. I need narrow spacing around the first division sign and broad spacing around the second. How can I do this?

Reproducible code:

# just produces uniform spacing:
plot( runif(10), runif(10) )
title( expression( 64 %/% 8 %/% 8 ) )

# returns an error
plot( runif(10), runif(10) )
title( expression( 64 %/% 8 ~ " " ~ %/% ~ " " 8 ) )
baixiwei
  • 1,009
  • 4
  • 20
  • 27
  • Is there a reason you don't just do `title( expression( (64 %/% 8) %/% 8 ) )` or `title( expression( over((64 %/% 8) , 8 ) ))`. Seems like that would be more clear. – MrFlick Jul 10 '14 at 14:46
  • 1
    Yes - the mathematical expressions are actually stimuli from an experiment designed specifically to investigate how variation in spacing affects how people interpret the expressions. I need to match the physical properties of the actual stimuli as exactly as possible - not just transmit an equivalent meaning. – baixiwei Jul 10 '14 at 14:50

1 Answers1

1

I second @MrFlick's comment above, but here is one way using phantom:

title(expression(paste(64 %/% 8, phantom(0) %/% phantom(0), 8)))
Matthew Plourde
  • 43,932
  • 7
  • 96
  • 113