You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed several cases where folks want to plot labels formatted in a certain way (in bold, in italics, etc.) where BPG defaults fail to do this automatically. This is particularly annoying when parts of the string are formatted correctly, while others are not. The solutions are to convert text to expressions and manually insert formatting code. Examples of recent discussions: #127#171
Another recent use-case I've encountered: needing to re-format an entire vector of axis labels. With more than a dozen labels, it is not feasible to manually write out custom expressions to account for each substring. It also required me to learn the entire unintuitive language of expression syntax. Something that could ease this process is a utility function that automatically converts all the characters in a string to expression syntax, e.g. ' ' to ~, inserting * where necessary, and excepting special characters.
For example, I have a vector of labels along the lines of c('red vs. blue', 'red vs. green')
I would like to format the "vs" in italics.
Desired final expression: bold(red~bolditalic(vs\\.)~blue)
Note that the period is a special character.
Next step would be to wrap the expression-ified string in bquote or parse, and pass to e.g. yaxis.lab.
I'm not sure how you could paramaterize inserting unique formatting onto a specific substring, however you could ease the journey by handling all the special expression syntax first. Here is what my imaginary text.to.expression.string would look like:
I've noticed several cases where folks want to plot labels formatted in a certain way (in bold, in italics, etc.) where BPG defaults fail to do this automatically. This is particularly annoying when parts of the string are formatted correctly, while others are not. The solutions are to convert text to expressions and manually insert formatting code. Examples of recent discussions: #127 #171
Another recent use-case I've encountered: needing to re-format an entire vector of axis labels. With more than a dozen labels, it is not feasible to manually write out custom expressions to account for each substring. It also required me to learn the entire unintuitive language of expression syntax. Something that could ease this process is a utility function that automatically converts all the characters in a string to expression syntax, e.g. ' ' to
~
, inserting*
where necessary, and excepting special characters.For example, I have a vector of labels along the lines of
c('red vs. blue', 'red vs. green')
I would like to format the "vs" in italics.
Desired final expression:
bold(red~bolditalic(vs\\.)~blue)
Note that the period is a special character.
Next step would be to wrap the expression-ified string in bquote or parse, and pass to e.g.
yaxis.lab
.I'm not sure how you could paramaterize inserting unique formatting onto a specific substring, however you could ease the journey by handling all the special expression syntax first. Here is what my imaginary
text.to.expression.string
would look like:Can something like
text.to.expression.string()
be added as a BPG function?The text was updated successfully, but these errors were encountered: