Git Product home page Git Product logo

fngr's Introduction

You can download this repository using devtools

# install.packages("devtools")
devtools::install_github("ben-williams/FNGr")

Then load the package per usual

library(FNGr)
library(tidyverse)
library(scales)
windowsFonts(Times=windowsFont("TT Times New Roman"))

First set the "universal" figure theme to theme_sleek() (based off of https://github.com/seananderson/ggsidekick)

theme_set(theme_sleek())

Create data for this example

data.frame(year = 1973:2017, age = 1:5) %>%
  mutate(y = rnorm(n(), 10,5)) -> df

The basic ggplot figure spaces years about every 5-10, depending on the timeseries length.

ggplot(df, aes(year, age, size = y)) + geom_point()  + scale_size_area()

This makes for a rather poor axis, for our typical presentation needs. We can clean this up somewhat by using breaks or the pretty_breaks function from the scales package

ggplot(df, aes(year, age, size = y)) + geom_point() + scale_size_area() +
    scale_x_continuous(breaks = seq(1973, 2016, 3))

ggplot(df, aes(year, age, size = y)) + geom_point() +
  scale_x_continuous(breaks = pretty_breaks(n = 15))

However this does not show a tick for each year, something that has been regularly requested. tickr will add a tick mark to each year and provide a label for the interval designated.

Labels every 10 years.

xaxis = tickr(df, year, 10)
yaxis = tickr(df, age, 2)

ggplot(df, aes(year, age, size = y)) + geom_point() +
  scale_x_continuous(breaks = xaxis$breaks, labels = xaxis$labels) +
  scale_y_continuous(breaks = yaxis$breaks, labels = yaxis$labels)

fngr's People

Contributors

jysullivan avatar

Watchers

James Cloos avatar Ben Williams avatar

Forkers

jysullivan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.