GithubHelp home page GithubHelp logo

rnabioco / ggtrace Goto Github PK

View Code? Open in Web Editor NEW
15.0 15.0 2.0 35.31 MB

ggplot2 geoms to outline groups of data points

Home Page: https://rnabioco.github.io/ggtrace

License: Other

R 100.00%
ggplot2 ggplot2-geom visualization

ggtrace's People

Contributors

jayhesselberth avatar raysinensis avatar sheridar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ggtrace's Issues

legend entries when trace_position is predicate

  • Currently all colours are included in legend when user passes a predicate to trace_position and modifies background_color
  • Could update this to exclude colours that are no longer shown on the plot
  • Could add a new entry to legend for the background_color, the name of this entry could be the expression passed to trace_position

tidy Imports/Suggests

consider eliminating glue, rlang, scales, RColorBrewer

will make for easier maintenance down the line

trace_position tidy evaluation

Currently an expression passed to trace_position is captured with substitute() and evaluated strictly within the context of the data. This means the user cannot use environment variables with trace_position. Ideally the user would be able to include both environment and data variables such as in the example below, which does not work with ggtrace v0.2.0.

To accomplish this, need to include a data mask (with rlang::eval_tidy()) when evaluating trace_position

create_trace_plot <- function(data, traceVar = "xVar", traceThreshold = -1) {

  pl <- ggplot(data = data, aes(xVar, yVar, fill = fill_var), color = "#000000") +
    geom_point_trace(
      trace_position = !!sym(traceVar) < traceThreshold,

      fill = "#FFFFFF",
      background_params = list(color = "#000000", fill = "#CC0000")
    ) +
    ggtitle(str_c("Threshold: ", traceThreshold))

  pl
}

trace_position predicate line break

This should result in line break:

stocks %>%
  ggplot(aes(day, value, color = name)) +
  geom_line_trace(trace_position = day < 100 | day > 1200)

To fix can add NAs instead of filtering data

default colors

  • Current default fill color is white, maybe change this to black
  • If predicate is passed to trace_position, will result in white points that are not outlined

group ordering with trace_position predicate

  • When a predicate is passed to geom_line_trace() trace_position, default ordering is changed
  • Due to how line breaks are handled with trace_position predicate
# good ordering
stocks %>%
  ggplot(aes(day, value, color = name)) +
  geom_line_trace()

# bad ordering
stocks %>%
  ggplot(aes(day, value, color = name)) +
  geom_line_trace(trace_position = day < 100)

update readme

Eliminate tidyverse and cowplot because they're not in Import / Suggests

just use

library(ggplot2)
library(ggtrace)

and e.g. theme_minimal() instead of the cowplot one.

Release ggtrace 0.2.0

First release:

Prepare for release:

  • git pull
  • Check if any deprecation processes should be advanced, as described in Gradual deprecation
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • git push
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Revise arguments

  • would be simpler to use 'fill' and 'color' instead of 'color' and 'trace_color'
  • would eliminate the need for new 'scale' functions

performance

  • assess performance
  • likely much slower than geom_point() and geom_line() since geom_*_trace() functions draw groups separately

group order with scale_*_manual

  • Order of groups changes when scale_*_manual() is used to modify aesthetics
# Order should be alphabetical (CAC, DAX, FTSE, SMI)
clrs <- c(
  CAC  = "#E69F00",
  DAX  = "#0072B2",
  SMI  = "#56B4E9",
  FTSE = "#009E73"
)

p +
  geom_line_trace(stroke = 1) +
  scale_color_manual(values = clrs)

geom_line_trace groups when using trace_position predicate

  • geom_line() needs groups so it knows how to draw each line
  • groups get set when mapping variables to aesthetics (color = variable)
  • when passing a predicate to trace_position, groups set by color are overwritten since the background layer by default is not outlined (color = NA)
  • this does not affect geom_point_trace() since groups are not needed to correctly draw points
# works
economics_long %>%
  ggplot(aes(date, value01, color = variable)) +
  geom_line_trace()

economics_long %>%
  ggplot(aes(date, value01, fill = variable)) +
  geom_line_trace(trace_position = variable == "pce")

# broken
economics_long %>%
  ggplot(aes(date, value01, color = variable)) +
  geom_line_trace(trace_position = variable == "pce")

CRAN comments

The main comment from CRAN is below. To my knowledge, the package doesn't modify the global environment, the <<- operator isn't used. Hmm going to look into this more..

Please do not modifiy the .GlobalEnv. This is not allowed by the CRAN policies.

background params

  • could allow user to pass a named list of parameters to control aesthetics of background data points

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.