tickr

Making consistent tick marks for R plots

https://github.com/ben-williams/tickr

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.1%) to scientific vocabulary

Keywords

axis-labels ggplot2 ticks
Last synced: 6 months ago · JSON representation

Repository

Making consistent tick marks for R plots

Basic Info
  • Host: GitHub
  • Owner: ben-williams
  • License: other
  • Language: R
  • Default Branch: main
  • Homepage:
  • Size: 56.6 KB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • Open Issues: 1
  • Releases: 1
Topics
axis-labels ggplot2 ticks
Created 11 months ago · Last pushed 11 months ago
Metadata Files
Readme License

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# tickr


![CRAN/METACRAN Version](https://img.shields.io/cran/v/tickr)


This is a small package to provide consistent tick marks for plotting `ggplot2` figures. 
It provides breaks and labels for ggplot2 without requiring ggplot2 to be installed.

## Installation

You can install the development version of `tickr` from GitHub:

``` r
# install.packages("remotes")
remotes::install_github("BenWilliams-NOAA/tickr")
```

## Example

```{r setup}
library(tickr)
library(ggplot2)
library(dplyr)
```

Some basic examples of how to use the `tickr` package.

```{r}
# Create a data.frame
df <- data.frame(year = 2000:2020,
                 spawning_biomass = rnorm(21,100, 0.25))

# explore tickr output
tickr(df, var=year)
tickr(df, var=year, by=2)
tickr(df, var=year, by=5, var_min = 1998, var_max = 2024, lab_start = 1998, lab_end = 2017)
tickr(df, var=year, by=5, var_min = 1998, var_max = 2024, lab_start = 1998, lab_end = 2017)

# explore plotting options
# default ggplot
ggplot(df, aes(year, spawning_biomass)) + 
  geom_line() +
  geom_point()

# a tick mark for every year
ggplot(df, aes(year, spawning_biomass)) + 
  geom_line() +
  geom_point() +
  scale_x_tickr(data=df, var=year)

# a tick mark for every year & label every 2nd year
ggplot(df, aes(year, spawning_biomass)) + 
  geom_line() +
  geom_point() +
  scale_x_tickr(data=df, var=year, by = 2)

# determine the years that are labeled
ggplot(df, aes(year, spawning_biomass)) + 
  geom_line() +
  geom_point() +
  scale_x_tickr(data=df, var=year, by = 5, 
                var_min = 1997, 
                var_max = 2024, 
                lab_start = 1997) 

# determine the years that are labeled
ggplot(df, aes(year, spawning_biomass)) + 
  geom_line() +
  geom_point() +
  scale_x_tickr(data=df, var=year, by = 2, 
                var_min = 2010, 
                lab_start = 2010)

# show future years
ggplot(df, aes(year, spawning_biomass)) + 
  geom_line() +
  geom_point() +
  scale_x_tickr(data=df, var=year, by = 5, 
                var_min = 2015, 
                var_max = 2026, 
                lab_start = 2015, 
                lab_end = 2026) +
  expand_limits(x = c(1998, 2026)) 

```

The same general approach is available for y axes as well.

```{r}
df <- expand.grid(age = 1:10,
                 year = 2000:2009) %>% 
  dplyr::mutate(value = rnorm(100, 1, 1))

df %>% 
  ggplot(aes(year, age, size=value)) + 
  geom_point() +
  scale_size_area() +
  scale_x_tickr(data=df, var=year, by=2, var_max = 2012, lab_end = 2012) +
  scale_y_tickr(data=df, var=age, by=2) +
  expand_limits(y=0, x=2012)


```

Owner

  • Name: Ben Williams
  • Login: ben-williams
  • Kind: user
  • Location: Juneau, Alaska

Personal account. See @BenWilliams-NOAA for professional account.

GitHub Events

Total
  • Release event: 1
  • Watch event: 1
  • Push event: 2
  • Pull request event: 1
  • Fork event: 1
  • Create event: 3
Last Year
  • Release event: 1
  • Watch event: 1
  • Push event: 2
  • Pull request event: 1
  • Fork event: 1
  • Create event: 3

Packages

  • Total packages: 1
  • Total downloads:
    • cran 150 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
cran.r-project.org: tickr

Consistent Axis Tick Marks

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 150 Last month
Rankings
Dependent packages count: 26.8%
Dependent repos count: 33.0%
Average: 48.8%
Downloads: 86.7%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • ggplot2 * imports
  • magrittr * imports
  • rlang * imports
  • knitr * suggests
  • rmarkdown * suggests
  • testthat >= 3.0.0 suggests