355
questions
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-...
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)
...
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
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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
...
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 ...
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 ...
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 ...
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&...
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 ...
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,...
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 ...
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 ...
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,...
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 ...
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 ...
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 ...
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&...
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-...
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 ...
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
...
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 ...
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 ...
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,...
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 &...
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", &...
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&...
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 ...
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....
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(...
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", "...
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 ...
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 <...
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 ...
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 ...
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 <-
"...
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....
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 ...
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 ...
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 ...
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 &...
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, ...
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 ...
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 : ...