Questions tagged [ggtext]

Advanced text formatting in ggplot2, enables the rendering of complex formatted plot labels.

The ggtext package enables using (a limited subset of) Markdown and HTML syntax in ggplot2 plot labels.

Repositories:

77 questions
3
votes
2 answers

How to fix ggtext´s rendering of combining characters like Ě or Ö?

I have an issue with my labels using **ggtext**, if I use combining characters like ĚŠČŘŽ or ÖÜÄ, element_markdown() will add additional spaces/render whitespace behind my text. My code looks like this:…
CZ_8eer
  • 45
  • 4
3
votes
1 answer

ggtext and element_markdown() expands horizontal spacing?

I am using ggtext's element_markdown to modify a subtitle, and to add color to one word, that is in a plot_annotation layer. My code is as follows: p1 + p1 + plot_layout(nrow = 2, heights = c(4, 1.8)) + plot_annotation(title = "The Rise of…
wcbrown
  • 157
  • 7
3
votes
0 answers

ggplot: fonts not found and strange spacing (maybe related to macOS)

I am struggling to apply fonts in ggplot on macOS and need some help. Hopefully this will help others too as I've searched a lot and tried all sorts to no avail. Fonts that appear to be there are not recognised and then strange spacing happens…
Chris
  • 1,449
  • 1
  • 18
  • 39
3
votes
1 answer

How to use LaTeX expression in textbox of ggplot

I have below ggplot : library(ggplot2) library(ggtext) library(ggdist) library(latex2exp) set.seed(123) DF <- rbind(data.frame('Label' = 'A', val = rnorm(200, 5)), data.frame('Label' = 'B', val = rnorm(500, 10))) ggplot(DF, aes(Label,…
Brian Smith
  • 1,200
  • 4
  • 16
3
votes
2 answers

ggplot2: How to dynamically wrap/resize/rescale x axis labels so they won't overlap

I'm trying to achieve a solution for wrapping x axis labels so they won't overlap. I know this question has been asked several times, and that there are some good answers. However, no solution that I've seen answers how to re-wrap the labels as the…
Emman
  • 3,695
  • 2
  • 20
  • 44
3
votes
1 answer

Changing one character in axis tick labels to italic while keeping multiple lines

I have a geom_col from ggplot2 with labels for categorical axis ticks like below: That plot was created with the following…
geoscience123
  • 164
  • 1
  • 11
3
votes
2 answers

Multipanel plots with spanning figure legend in R with ggtext and gridtext in R

I am close to achieving this multipanel plot with a spanning textgrob figure legend below. But I continue to get an unexpected amount of space between the figures and the figure legend. Attempt in the reprex below. # Library…
phiggins
  • 248
  • 1
  • 7
2
votes
3 answers

Cannot conditionally make axis labels bold in ggplot

I am trying to make select axis labels bold, based on a conditional from a different column. In the code below, if Signif equals 1, then the Predictor axis text should be bold. In addition, the segments should appear in the order of Values …
Adam_G
  • 7,337
  • 20
  • 86
  • 148
2
votes
1 answer

troubleshooting fonts in ggtext/markdown labels

I'm trying to use ggtext::geom_richtext() to create bold/italic text (on Pop!OS [Ubuntu derivative] 22.04 with R-devel). I only get plain text (using PNG or PDF or using an on-screen X11/cairo device). The output all looks plain in every format. (I…
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
2
votes
1 answer

How to add icons to ggplot captions and titles?

Right now I am trying to put icons in ggplot visualizations. To this end, I have checked a couple of tutorials on the web and when I run the following code example of Claus Wilke, library(ggtext) library(ggplot2) ggplot(mtcars) + aes(mpg, disp)…
mzkrc
  • 219
  • 2
  • 7
2
votes
1 answer

ggtext : element_markdown not working with position = "top"

I have a chart (simplified example below) where I want to put the x-axis at the top. The labels use element_markdown to include line breaks. It all works fine until I add position = "top" which seems to stop the line break being applied. Do you…
Chris
  • 1,449
  • 1
  • 18
  • 39
2
votes
2 answers

Reduce superscript font size ggplot2 R

I'm developing a script with ggplot2 and the package ggtext to produce some plots with superscripts next to the title that further are grouped in a reference table. A simplified example of what I'm doing…
2
votes
2 answers

R: add custom legend to ggplot

I have the following plot: And would like to add a legend as follows: This is the code I used to generate the plot: library(data.table) library(ggplot2) blue <- "#4472C4" green <- "#548235" red <- "#C55A11" redblood <- "#C00000" DT <-…
mat
  • 2,412
  • 5
  • 31
  • 69
2
votes
2 answers

What formatting language does ggtext use to format text?

I am trying to display scientific notation on a ggplot2 axis in boldface, with the literal "Ax10^B" format, not "AeB" format that is the default of ggplot2. When this code is run library(tidyverse) library(ggtext) ggplot(mpg, aes(displ, hwy*10^9)) +…
Jordan Mandel
  • 478
  • 3
  • 14
2
votes
1 answer

Verify font availability in R

I have a font installed on my OS, so this code runs fine: library(tidyverse) library(extrafont) iris %>% ggplot(aes(Sepal.Length,Sepal.Width, color = Species)) + geom_point(size = 2) + theme( text = element_text(family = "Metropolis") ) Let's…
Alexis
  • 2,104
  • 2
  • 19
  • 40