Code Monkey home page Code Monkey logo

ggvenn's Introduction

ggvenn

An R package that draws modifiable venn diagrams in ggplot2. The venn diagrams can easily be modified and added to an existing ggplot object. ggvenn uses base R functions to convert the data into a format that is than vizualized using ggplot2's geom_polygon layer.

Installation

Install the package from the git repository:

devtools::install_github("nicolash2/ggvenn")

Create a venn diagram

Load the package, create your venn diagrams. ggvenn can create venn diagrams with up to 5 sets. A theme_void normally goes will with venn diagrams.

library(ggvenn)
library(ggplot2)

#to showcase ggvenn, let's create a test set list. It is simply a list of vectors.
set1 <- rownames(subset(mtcars, mpg>18))
set2 <- rownames(subset(mtcars, qsec>18))
set3 <- rownames(subset(mtcars, cyl<5))
set4 <- rownames(subset(mtcars, wt>2.5))
set5 <- rownames(subset(mtcars, gear==4))
carset <- list(mpg=set1, qsec=set2, cyl=set3, wt=set4, gear=set5)

ggplot() + 
  geom_venn(carset) +
  theme_void()

You can change all the usual ggplot parameters and add additional layers. You can also change the position of the venn diagram with the xlim and ylim arguements. Note, that by default, geom_venn will force the graph to be a square. If you don't want that, specify fixedCoords=FALSE.

Modifying the colors is done in the same way you would do normally:

ggplot() + geom_venn(setlist[1:3]) +
  scale_fill_manual(values=c("red","blue","yellow")) +
  theme_void()

The geom_venn function will take all parameters valid for geom_polygon and geom_text and apply them accordingly, with 2 exceptions: the size and color arguements of the text will be set via the geom_venn arguements textsize and textcolor.

ggplot() + geom_venn(setlist[1:3], color="red", size=4, textsize=10, textcolor="blue") +
  theme_void()

ggvenn's People

Contributors

nicolash2 avatar

Stargazers

 avatar

Watchers

 avatar

ggvenn's Issues

ggeuler should be renamed

Thanks for the contribution, though I'm pretty sure your ggeuler does Venn diagrams, not Euler plots.

Installation fails on R4.1.2: undefined exports: geom_euler

Attempted to install this package according to the instructions in the README, and got this error:

> devtools::install_github("nicolash2/ggvenn")
Downloading GitHub repo nicolash2/ggvenn@HEADchecking for file/tmp/Rtmp8LG4RT/remotes4930512dfc52/NicolasH2-ggvenn-28c0c60/DESCRIPTION’ (917ms)
─  preparingggeuler:checking DESCRIPTION meta-information ...checking for LF line-endings in source and make files and shell scriptschecking for empty or unneeded directories
   OmittedLazyDatafrom DESCRIPTIONbuildingggeuler_0.1.0.tar.gz* installing *source* packageggeuler...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed forggeulerin namespaceExport(ns, exports):
 undefined exports: geom_euler
Error: loading failed
Execution halted
ERROR: loading failed
* removing<R_HOME>/library/ggeulerWarning message:
In i.p(...) :
  installation of package/tmp/Rtmp8LG4RT/file4930495836cb/ggeuler_0.1.0.tar.gzhad non-zero exit status

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.