Coder Social home page Coder Social logo

ggtech's Introduction

title output
ggplot2 tech themes, scales, and geoms
html_document
fig_height fig_width keep_md
5
10
true

Install ggtech:

devtools::install_github("ricardo-bion/ggtech", 
                          dependencies=TRUE)

Use ggtech:

Make sure to install the required fonts (instructions at the end of this file).

library(ggtech)

d <- qplot(carat, data = diamonds[diamonds$color %in%LETTERS[4:7], ], geom = "histogram", bins=30, fill = color)

Tech themes and scales:

d + theme_tech(theme="airbnb") + 
  scale_fill_tech(theme="airbnb") + 
  labs(title="Airbnb theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d + theme_airbnb_fancy() + 
  scale_fill_tech(theme="airbnb")  + 
  labs(title="Airbnb theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d + theme_tech(theme="etsy") + 
  scale_fill_tech(theme="etsy") + 
  labs(title="Etsy theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d + theme_tech(theme="facebook") +
  scale_fill_tech(theme="facebook") + 
  labs(title="Facebook theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d + theme_tech(theme="google") + 
  scale_fill_tech(theme="google") + 
  labs(title="Google theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d + theme_tech(theme="twitter") + 
  scale_fill_tech(theme="twitter") + 
  labs(title="Twitter theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d + theme_tech(theme="X23andme") + 
  scale_fill_tech(theme="X23andme") + 
  labs(title="23andme theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

Tech color scales:

data("iris")

d1 <- qplot(x  = Sepal.Length, y =Sepal.Width,colour = Species,data = iris,geom = "point")
d1 + theme_tech(theme="airbnb") + 
  scale_color_tech(theme="airbnb") + 
  labs(title="Airbnb theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d1 + theme_airbnb_fancy() + 
  scale_color_tech(theme="airbnb")  + 
  labs(title="Airbnb theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d1 + theme_tech(theme="etsy") + 
  scale_color_tech(theme="etsy") + 
  labs(title="Etsy theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d1 + theme_tech(theme="facebook") +
  scale_color_tech(theme="facebook") + 
  labs(title="Facebook theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d1 + theme_tech(theme="google") + 
  scale_color_tech(theme="google") + 
  labs(title="Google theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d1 + theme_tech(theme="twitter") + 
  scale_color_tech(theme="twitter") + 
  labs(title="Twitter theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

d1 + theme_tech(theme="X23andme") + 
  scale_color_tech(theme="X23andme") + 
  labs(title="23andme theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

Tech geoms, inspired by emoGG.

d2 <- data.frame(x = c(1:4, 3:1), y=1:7)
ggplot(aes(x,y), data=d2) + 
  geom_tech(size=0.25, theme="airbnb") + 
  theme_tech("airbnb") +
  ggtitle("Airbnb geom")

ggplot(aes(x,y), data=d2) + 
  geom_tech(size=0.15, theme="etsy") + 
  theme_tech("etsy")+
  ggtitle("Etsy geom")

ggplot(aes(x,y), data=d2) + 
  geom_tech(size=0.15, theme="facebook") + 
  theme_tech("facebook")+
  ggtitle("Facebook geom")

ggplot(aes(x,y), data=d2) + 
  geom_tech(size=0.25, theme="google") + 
  theme_tech("google" ) +
  ggtitle("Google geom")

ggplot(aes(x,y), data=d2) + 
  geom_tech(size=0.15, theme="twitter") + 
  theme_tech("twitter") +
  ggtitle("Twitter geom")

ggplot(aes(x,y), data=d2) + 
  geom_tech(size=0.15, theme="X23andme") + 
  theme_tech("X23andme") +
  ggtitle("23andme geom")

Install fonts:

You have to install the necessary fonts manually before using ggtech. Mofidy the destfile if you are using Windows or Unix.

library(extrafont)

## Facebook 
download.file("http://social-fonts.com/assets/fonts/facebook-letter-faces/facebook-letter-faces.ttf", "/Library/Fonts/facebook-letter-faces.ttf", method="curl")

font_import(pattern = 'facebook-letter-faces.ttf', prompt=FALSE)


## Google 
download.file("http://social-fonts.com/assets/fonts/product-sans/product-sans.ttf", "/Library/Fonts/product-sans.ttf", method="curl")

font_import(pattern = 'product-sans.ttf', prompt=FALSE)


## Airbnb 
download.file("https://dl.dropboxusercontent.com/u/2364714/airbnb_ttf_fonts/Circular%20Air-Medium%203.46.45%20PM.ttf", "/Library/Fonts/Circular Air-Medium 3.46.45 PM.ttf", method="curl")

download.file("https://dl.dropboxusercontent.com/u/2364714/airbnb_ttf_fonts/Circular%20Air-Bold%203.46.45%20PM.ttf", "/Library/Fonts/Circular Air-Bold 3.46.45 PM.ttf", method="curl")

font_import(pattern = 'Circular', prompt=FALSE)


## Etsy 
download.file("https://www.etsy.com/assets/type/Guardian-EgypTT-Text-Regular.ttf", "/Library/Fonts/Guardian-EgypTT-Text-Regular.ttf", method="curl")

font_import(pattern = 'Guardian-EgypTT-Text-Regular.ttf', prompt=FALSE)


## Twitter 
download.file("http://social-fonts.com/assets/fonts/pico-black/pico-black.ttf", "/Library/Fonts/pico-black.ttf", method="curl")

download.file("http://social-fonts.com/assets/fonts/arista-light/arista-light.ttf", "/Library/Fonts/arista-light.ttf", method="curl")

font_import(pattern = 'pico-black.ttf', prompt=FALSE)
font_import(pattern = 'arista-light.ttf', prompt=FALSE)

ggtech's People

Contributors

adraginda avatar ricardo-bion avatar ricardobion avatar welch16 avatar

Stargazers

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

Watchers

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

ggtech's Issues

When calling theme_tech: "plot.subtitle" is not a valid theme element name

The example code fails with the following error:

library(ggtech)

d <- qplot(carat, data = diamonds[diamonds$color %in% LETTERS[4:7], ], 
geom = "histogram", bins=30, fill = color)

d + theme_tech(theme="google") + 
  scale_fill_tech(theme="google") + 
  labs(title="Google theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

Error in (function (el, elname) : "plot.subtitle" is not a valid theme element name.

scale_fill_tech works on its own, so the issue concerns theme_tech.

I'm fully up to date: R 3.3.0, ggtech_0.1, ggplot2_2.1.0

Warning messages of font family

I tried the first example and there were warning messages coming out.

library(ggplot2)
library(ggtech)
d <- qplot(carat, data = diamonds[diamonds$color %in%LETTERS[4:7], ], geom = "histogram", bins=30, fill = color)
d + theme_tech(theme="airbnb") + 
  scale_fill_tech(theme="airbnb") + 
  labs(title="Airbnb theme", 
       subtitle="now with subtitles for ggplot2 >= 2.1.0")

Warning messages were

Warning messages:
1: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
2: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
3: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
4: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
5: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
6: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
7: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
8: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
9: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
10: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
11: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
12: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
13: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
14: In grid.Call.graphics(L_text, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
15: In grid.Call.graphics(L_text, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
16: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
17: In grid.Call(L_textBounds, as.graphicsAnnot(x$label),  ... :
  font family not found in Windows font database
There were 32 warnings (use warnings() to see them)

My sessionInfo is

R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936   
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C                              
[5] LC_TIME=Chinese (Simplified)_China.936    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggtech_0.1    ggplot2_2.2.1

loaded via a namespace (and not attached):
 [1] labeling_0.3     colorspace_1.3-2 scales_0.4.1     assertthat_0.1   lazyeval_0.2.0   plyr_1.8.4       tools_3.3.2     
 [8] gtable_0.2.0     tibble_1.2       Rcpp_0.12.8      grid_3.3.2       digest_0.6.10    munsell_0.4.3

Thank you very much for you attention!

I have also installed the extrafonts.

Font scripting error

I installed fonts as per the instructions, but this error keeps creeping up:

rsession[61577] <Error>: ATSFontGetPostScriptName failed: error -984.

The graph is built correctly and it displays the theme accordingly, but after about 40 of the same error messages...

Not sure if it has something to do with the fonts.

Here is session info, maybe something will pop-up that i'm not seeing...

R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.3 (Yosemite)

locale:
[1] es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_2.0.0 ggtech_0.1   

loaded via a namespace (and not attached):
 [1] labeling_0.3     colorspace_1.2-6 scales_0.3.0     plyr_1.8.3       tools_3.2.3     
 [6] gtable_0.1.2     Rcpp_0.12.3      grid_3.2.3       digest_0.6.9     munsell_0.4.3   

Economist theme

The Economist magazine has great visualizations. But I cannot find any fonts that match their custom typeface. Have you attempted this look?

fonts unavailable

I have found that most of the fonts in these themes are unavailable, do we need to manually download them on windows first?

Required font files appear to be invalid

I came across ggtech recently and it seemed like a great way to easily improve the design of my ggplots. However, there appear to be issues with the required font files which prevent them from being installed, at least on Windows 10.

  1. When trying to install the fonts as described via extrafont, the installation fails due to error messages as described here
  2. When trying to manually install the fonts into Windows, Windows argues that the file "is not a valid font file"
  3. Online font file type converters are also unable to convert the file type of the font files claiming similar error messages as Windows
  4. The Dropbox links are dead

Hope this helps!

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.