Home > Back-end >  Adding Greek letters and variables to a legend in plot R
Adding Greek letters and variables to a legend in plot R

Time:04-14

I want to print the variables z in the plot. I have added

sprintf(%1.1f,zChart

CodePudding user response:

Create the string and parse it.

labels <- parse(text = sprintf("sigma == %f", z))

Words can be separated with ~ symbols or combined into a single literal using quotes. * can be used for juxtaposition.

labels <- parse(text = sprintf("Case ~ (%d) ~ sigma == %f", 1:3, z))

labels <- parse(text = sprintf("Case ~ (%d) * ':' ~ sigma == %f", 1:3, z))

labels <- parse(text = sprintf("'Case (%d) sigma' == %f", 1:3, z))

labels <- parse(text = sprintf("'Case (%d): sigma' == %f", 1:3, z))

Try demo("plotmath") for more info.

  •  Tags:  
  • r
  • Related