0

Finally figured out how to make my riverplot in R, now I'm wondering how to make my font size smaller?

    library(riverplot)

    #Bring in file of nodes and edges
    nodes <- read_xlsx("riverplot_cell_p.xlsx", sheet = "nodes")
    edges <- read_xlsx("riverplot_cell_p.xlsx", sheet = "edges")

    #Convert to data frame
    nodes <- as.data.frame(nodes)
    edges <- as.data.frame(edges)
    rownames(nodes) = nodes$ID


    #Construct a list of styles
    library(RColorBrewer)
    palette = paste0(brewer.pal(9, "Set1"), "60")
    styles = lapply(nodes$y, function(n) {
      list(col = palette[n+1], lty = 0, textcol = "black")})
    names(styles) = nodes$ID

    #Construct riverplot
    library(riverplot)
    rp <- list(nodes = nodes, edges = edges, styles = styles)
    class(rp) <- c(class(rp), "riverplot")
    plot(rp)

[riverplot[1]

Phil
  • 7,287
  • 3
  • 36
  • 66
Shannon R
  • 11
  • 2
  • 1
    Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use `str()`, `head()` or screenshot)? You can use the [`reprex`](https://reprex.tidyverse.org/articles/articles/magic-reprex.html) and [`datapasta`](https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) packages to assist you with that. See also [Help me Help you](https://speakerdeck.com/jennybc/reprex-help-me-help-you?slide=5) & [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269) – Tung Feb 10 '20 at 04:58

2 Answers2

0

I can't see any way to change the text font size from the help page of plot.riverplot, but you can always modify the dimensions of the graphics device using the width/height arguments. For example:

w <- 3 # tinker with these multipliers
h <- 2
tiff(file="Figure_1.tiff", width=480*w, height=480*h)
plot(rp)
dev.off()

See if that works.

Edward
  • 10,360
  • 2
  • 11
  • 26
0

You can set test size in your styles list using:

textcex=1.5