Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
42 views

Create new pdf with decreasing font text ( by line) repeating every 9 lines in R

I've been running this code without success, but I don't know why it's not working. My goal is to change the font of a pdf line-by-line, decreasing from biggest to smallest, every 9 lines (e.g., 12-...
Haley's user avatar
  • 43
2 votes
1 answer
81 views

How to avoid margins with wide spplot?

I am generating graphics with spplot and I have margin problems. library(sp) library(grid) library(gridExtra) demo(meuse, ask = FALSE, echo = FALSE) p = spplot(meuse, c("zinc"), aspect=0.1) ...
Jérôme Tremblay's user avatar
0 votes
1 answer
48 views

How to hack a grid::grob object in R to change existing text or add new?

EDIT I don't have the underlying counts, just the end values for proportions. Original Post I have summary data for set intersections that I wish to visualize with R. Probability of A: 0.2 ...
Emman's user avatar
  • 4,147
1 vote
0 answers
51 views

How does grid determine xscale and yscale values in a new R session and how should they be interpreted?

When I start an R session, the xscale and yscale values of the initial viewport are set automatically by the grid package. I would like to understand the relationship between these values and the ...
David Romano's user avatar
1 vote
0 answers
58 views

Is there a way to move the legend in a trackViewer lollipopPlot and/or change its orientation?

Is there any way to alter the position or orientation of a legend in a trackViewer lollipopPlot (or fudge something that performs the same function), so that it's on the side of the plot and directly ...
KeyboardCat's user avatar
1 vote
1 answer
94 views

Title and legend adjustment with `grid.arrange`

I have 6 different plots in R that I want to arrange in one plot with grid.arrange. They share the same legend, but whenever I want to put a common legend, the sizes of the plots are adjusted ...
Masal Gezici's user avatar
1 vote
1 answer
225 views

How to assign unique colors to multiple vertical lines in R forestplot?

I am using forestplot and want to put a series of vertical lines in the figure. I am successful adding as many lines as I want, using the grid argument. But, I would like to assign a different color ...
Io Ferenghetti's user avatar
1 vote
1 answer
251 views

arrangeGrob() and similar alternatives do not accept a list of grobs . At grid.draw, returns: Error in gList(...) : only 'grobs' allowed in "gList"

I am making a large volume of plots from survey data that requires the entire text of each question to be displayed next to the resulting bar chart. Arranging a grid of grobs seems the best way to do ...
Bart Yarborough's user avatar
0 votes
2 answers
71 views

Add logo to ggplot2 in a loop

I'm trying to utilize the method outlined here to add a logo to a plot, but in a loop. It works fine for one plot, but in a loop it doesn't print as expected. Note that the first R logo is placed ...
seansteele's user avatar
1 vote
0 answers
159 views

grid.newpage() conflicts with plot.new()

I am following this example to make a base graphics plot rotated 45 degrees. Now I came to a situation when I need to call grid.newpage() to basically clear the grid's viewport tree, but I also need ...
Tomas's user avatar
  • 59k
4 votes
1 answer
57 views

Using R 4.1.0's new `grid::pattern` function, how can I rotate a pattern

I am investigating the new pattern functionality of grid. So far, I can cross-hatch a rectangle: library(grid) # Note that using absolute coordinates like "cm" for # x and y does not work ...
akraf's user avatar
  • 3,202
0 votes
1 answer
153 views

Left align table in Grob

Is there a way to align a table in a Grob to the left side of the panel instead of having it centred? In the example bellow you can see that the table is in the centre of the lower panel, but I would ...
jpquast's user avatar
  • 335
1 vote
1 answer
80 views

Rotate a R plot with dynamic plot area

I'm trying to rotate a plot to be incorporated into a shiny application. I found how to rotate a plot. To get it right it seems you need to fiddle with the the height and width of the viewport making ...
mmoisse's user avatar
  • 150
0 votes
0 answers
28 views

Filling a circle with patterns in R using MikeFC's svgparser and minisvg

I can't replicate the result of filling the circle with the pattern object. It will only draw a circle with no pattern inside it. I am following MikeFC's instructions found here: text The entirety of ...
Jyn Taru's user avatar
0 votes
1 answer
64 views

why does it say unused argument for radius = unit(0.1, "snpc")

I am trying to create a graph with rounded corners, but when I put in the parameter radius =unit(0.1, "snpc") or radius = 0.1, both return 'unused argument (radius = unit(0.1, "snpc&...
lubalubadubdub's user avatar
0 votes
0 answers
66 views

R grid graphics: reducing resolution of raster image / grob

There is a couple of options for reading images in tiff format into R, including library(tiff), but also library(magick), library(terra) (as the successor of raster) and library(EBImage). I would only ...
NicolasBourbaki's user avatar
1 vote
1 answer
66 views

Drawing a grid grob on a scatterplot in R

How to add a grid grob (polygon) on a scatterplot in R ? With graphics::polygon it is possible. But with grid::polygonGrob with "native" unit, the grob is not plotted. rand <- rnorm(3000,...
Crops's user avatar
  • 5,126
0 votes
1 answer
762 views

Insert rectangle outside of ggplot to visualize plot segments

I hope you can help me. I have the idea of visualizing segments within a plot with a rectangle that can be placed next to the y or x-axis which means that it would be outside of the plot area. It ...
veka's user avatar
  • 37
2 votes
1 answer
157 views

Wrapping text in a tableGrob

I have a df with one column ("Reviewer Feedback") and two rows ("Reviewer 1" and "Reviewer 2"). I'm trying to wrap the text in the cells (the reviewer feedback) I keep ...
vashfive's user avatar
0 votes
1 answer
221 views

R - ggplot2: geom_text with fontsize scaled to window size

a function that I'm writing uses ggplot2::geom_text(). However, I need the fontsize to stay scaled to the window size, meaning: If the size of the window is decreased the fontsize has to decrease, too,...
kuecki95's user avatar
2 votes
0 answers
182 views

Offsetting a polyline in one direction part II

This is a follow-up question from: Offsetting a polyline in one direction. Essentially, I still want to offset a polyline in one direction, but, since asking the original question, I have become more ...
teunbrand's user avatar
  • 37.2k
0 votes
0 answers
82 views

read grid ascii from opendap output using R

I have grid ascii file from opendap output with 4 dimension attributes (time, depth, latitude, longitude), respectively. How to read/import this file into separated XYZ dataframe based on its ...
Eko Susilo's user avatar
1 vote
1 answer
196 views

Fetch outer dimensions to draw a bounding box from an irregular polygon grob in `R` using `grid`

I am trying to draw a bounding box around different polygon shapes in R with the grid functions grobX and gorbY. The polygons are drawn using the grid primitive function polygonGrob or grid.polygon. x ...
Crops's user avatar
  • 5,126
2 votes
0 answers
184 views

Calculate the width of a geom_text in ggplot2 [duplicate]

When adding text labels next to (or above) bars with geom_text, there is no way to automatically leave enough room for the label. Example: library(ggplot2) pdata <- data.frame(group = c("A&...
Remko Duursma's user avatar
1 vote
1 answer
126 views

par('usr') equivalent command for grid?

When grid package is used to plot a figure, I want to find out something similar to par('usr') as in base R graphics. What command can do it? https://r-graph-gallery.com/100-high-density-scatterplot-...
user1424739's user avatar
  • 13.2k
2 votes
0 answers
71 views

Edit or undo segment or text for real time plot in R

Say I want to display a web data stream in real time in a plot in R. Is there a way, to just draw and undraw the most recent text box or segment over the existing plot, rather than drawing the entire ...
Camilo's user avatar
  • 419
1 vote
0 answers
255 views

Superscript text_Grob [duplicate]

I have a fiddley little problem! I am trying to get a superscript (i.e. the -1 in "Mg:Ca(µmol mol-1)" into a text grob but can't find the correct annotation of the script: Axis labels ...
Angela Russell's user avatar
0 votes
0 answers
54 views

How to produce SVG that would fill the entire screen?

The code below creates a circle using the R grid graphics. I would expect the chart to fill the entire screen instead it fills only a fraction (top-left) of the screen. I am on a Windows computer and ...
ColorStatistics's user avatar
2 votes
2 answers
1k views

How to put y axis title in top left corner of graph using grid's functions?

I want to write the y-axis title horizontally on top of the y-axis line while keeping settings defined for the y-axis in the theme() function. The objective is to avoid wasting space while keeping a ...
Paul's user avatar
  • 2,947
2 votes
1 answer
129 views

Extract plotting region coordinates for grid.picture() in R

Background I am plotting the following image: Using this code: par(mfrow = c(2, 2), mar = c(2, 2, 2, 2)) plot(1, col = "red", pch = 15) plot(1, col = "blue", pch = 15) plot(1,...
Gimelist's user avatar
  • 821
1 vote
1 answer
61 views

Curve between two rectangles is not shown

I am trying to connect the two rectangles with a curved arrow, but no curve is drawn. Could you please help me? Thanks! library(grid) grid.newpage() pushViewport(plotViewport(c(2, 2, 2, 2))) xis &...
PaulS's user avatar
  • 23.9k
0 votes
1 answer
336 views

changing legend of faceted boxplot in ggplot2 to have groups with similar names inside

This question builds off of enter link description here but is in the context of faceted boxplots. So, I have the following code: set.seed(20210714) dd <- data.frame(Method = rep(c("A", &...
user3236841's user avatar
  • 1,225
2 votes
1 answer
4k views

changing the legends in ggplot2 to have groups of similar labels

this question builds off of this solution provided at enter link description here as follows. library(ggplot2) library(gtable) library(grid) diamonds$cut = factor(diamonds$cut, levels=c("Fair&...
user3236841's user avatar
  • 1,225
2 votes
1 answer
241 views

Convert a wordcloud to a grob / include it in grid.arrange (R)

I have built a more complex output via grid.arrange and now I want to include a wordcloud(2). The ggplot wordcloud function is not an option, since it works much slower for my task. But grid.arrange ...
Alex_'s user avatar
  • 189
1 vote
0 answers
133 views

Saving output plot in R with grid.grab() doesn't work

I've been trying to save multiple plot generated with the meta package in R, used to conduct meta-analysis, but I have some troubles. I need to save this plot to arrange them in a multiple plot figure....
userq8957289475's user avatar
3 votes
2 answers
2k views

Margin above title in ggplot created with grid.arrange

I have two ggplots that I can created like this: df1 = data.frame(x=1:10, y1=11:20, y2=21:30) gg1 = ggplot(df1) + geom_point(aes(x=x, y=y1)) gg2 = ggplot(df1) + geom_point(aes(x=x, y=y2)) grid.arrange(...
Robin Kohrs's user avatar
2 votes
1 answer
2k views

Plot table next to plot and below legend in ggplot2

I have this data frame and table: circ.plot <- structure(list(ID = c("GO:0010257", "GO:0097031", "GO:0032981", "GO:0006120", "GO:0046654", "...
justinian482's user avatar
  • 1,075
0 votes
1 answer
93 views

ragg anti-aliasing for touching polygons

I'm rendering a series of touching polygons with grid and saving this to a png file using the ragg package. Whenever I do this with the ragg package, I get a white grid atop my polygons where they ...
teunbrand's user avatar
  • 37.2k
0 votes
0 answers
137 views

hexbin and ggplot in different panels

I'd like to combine a hexbin plot with a ggplot in different panels in R. I can get kinda close, but it's still not working: library(hexbin) library(ggplot2) library(grid) x1 <- rnorm(100) y1 <...
Eden's user avatar
  • 425
0 votes
0 answers
336 views

how to arrange tables in specific place grid.arrange

I am using the gtable and gridExtra packages to manipulate PDF. I am struggling with setting the place manually for my tables i.e I would like to be both of the more in the center not so close to the ...
smox1's user avatar
  • 1
1 vote
1 answer
508 views

Is there a way to change background color or color the inverse of the input sets?

I'm working on a shiny app to let students explore the basic probability equations and notation with dynamic Euler (Venn) diagrams responding to changes in probability and displaying the intersection ...
naita's user avatar
  • 13
1 vote
0 answers
78 views

Choose font for transition diagram in GMisc

How can one change the text font in a transition diagram created with the GMisc package in R? I can get 2% of the way there as follows: library(grid) library(Gmisc) grid.newpage() txt <- "...
David Kaufman's user avatar
1 vote
1 answer
289 views

Is there any way to convert a gTree back to a workable ggplot in r?

Here is some example data: exampledata <- structure(list(x = c(2.93131952459005, 3.21275054434318, 1.36466997175509, 2.13626543532502, 1.45889556823722, 1.94598707699052, 0.719062322132357, 2....
ljh2001's user avatar
  • 463
4 votes
1 answer
835 views

Exact dimensions of linetype spacing and size

This is mostly a follow-up question on a previous one. Given that in ggplot2 and grid there are different linetypes and spacings vary between line sizes, what is their relationship? There are two ...
teunbrand's user avatar
  • 37.2k
10 votes
2 answers
1k views

How to keep linetype spacing constant despite line size

I've been attempting to plot lines in either ggplot2 or grid with equal spacing between line segments when the sizes differ. However I've not been succesfull so I ask you for help. In the examples ...
teunbrand's user avatar
  • 37.2k
1 vote
1 answer
438 views

Isn't this function for grid.arrange correct?

grid.arrange(hist1, hist2, nrow = 2) This is the line of code with error The error shown is ------------------------------------- Error in grid.arrange(hist1, hist2, nrow = 2) : could not find ...
Fatty Acids's user avatar
10 votes
3 answers
9k views

Combine multiple facet strips across columns in ggplot2 facet_wrap

I am trying to combine facet strips across two adjacent panels (there is always two adjacent ones with the same first ID variable, but with two different scenarios, let's call them "A" and &...
Björn's user avatar
  • 694
2 votes
1 answer
1k views

How to increase space among different boxes created for the facet labels using `facet_nested`?

I have a plot like this below: library(ggplot2) library(ggh4x) # remotes::install_github("teunbrand/ggh4x") df1 <- data.frame(x = rep(1:12, times=4, each=1), y = rep((1:12)^2, ...
Dekike's user avatar
  • 1,274
0 votes
1 answer
496 views

using grid to annotate lattice plots outside of the plotting region

I often use the lattice package to create figures. I then use grid::grid.text() to annotate the figures outside of the plotting region. Typically, I make PDF files, and there are no problems. I now ...
user697473's user avatar
  • 2,233
0 votes
1 answer
116 views

get the most common source-destination trajectories in R

I have two spatial points dataset, one for origins and one for destinations. I'd like to take the most recurring trajectories from these coordinates. > salidas class : ...
Ander Jarauta Álvarez's user avatar

1
2 3 4 5
8