https://github.com/rrwen/draw
Wrapper Functions for Producing Graphics
https://github.com/rrwen/draw
box circle curve diagram draw graphics grid line package page r rectangle reproducible shape square text triangle
Last synced: 10 months ago
JSON representation
Wrapper Functions for Producing Graphics
- Host: GitHub
- URL: https://github.com/rrwen/draw
- Owner: rrwen
- License: other
- Created: 2018-07-24T16:16:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-26T18:08:16.000Z (over 7 years ago)
- Last Synced: 2025-03-12T04:35:41.599Z (11 months ago)
- Topics: box, circle, curve, diagram, draw, graphics, grid, line, package, page, r, rectangle, reproducible, shape, square, text, triangle
- Language: R
- Homepage:
- Size: 65.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# draw
Richard Wen
rrwen.dev@gmail.com
A set of user-friendly wrapper functions for creating consistent graphics and diagrams with lines, common shapes, text, and page settings. Compatible with and based on the R 'grid' package.
## Install
1. Install [R](https://www.r-project.org/)
2. Install the [RStudio](https://www.rstudio.com/products/rstudio/download/#download) code editor
3. Open an [R Console](https://support.rstudio.com/hc/en-us/articles/200404846-Working-in-the-Console) in RStudio
3. Install [draw](https://github.com/rrwen/draw) in an R console with [install.packages](https://www.rdocumentation.org/packages/utils/versions/3.5.1/topics/install.packages)
```R
install.packages("draw")
```
## Usage
1. Load [draw](https://github.com/rrwen/draw) with [library](https://www.rdocumentation.org/packages/base/versions/3.5.1/topics/library)
2. Set page dimensions and units with `drawSettings`
3. Create a new page with `drawPage`
4. Draw graphics with `drawBox`, `drawCircle`, `drawLine`, `drawText`
5. Export graphics to a file with `drawExport`
```R
library(draw)
# Set drawing settings
drawSettings(pageWidth = 5, pageHeight = 5, units = "inches")
# Create a new drawing page
drawPage()
# Draw graphics on the page
drawBox(x = 2.5, y = 2.5, width = 1, height = 1)
drawCircle(x = 2.5, y = 2.5, radius = 0.5)
drawLine(x = c(1, 4),
y = c(1 ,1))
drawText(x = 2.5, y = 2.5, text = "TEXT")
# Export the drawing page to a PDF
drawExport("draw.pdf")
# Export the drawing page to a JPEG
drawExport("draw.jpeg", ppi = 300)
```