Code Monkey home page Code Monkey logo

110-1-economic-data-visualization's Introduction

110-1-Economic-Data-Visualization

Join the chat at https://gitter.im/110-1-EconDV/main

Gitter

110-1-economic-data-visualization's People

Contributors

gitter-badger avatar tpemartin avatar

Stargazers

 avatar

Watchers

 avatar  avatar

110-1-economic-data-visualization's Issues

axis_x_custom function building

dataSet1 <- 
  data.frame(
    x=1979:2018
  )
set.seed(2038)
dataSet1$y <- sample(10:40, length(dataSet1$x), T)
ggplot1 <- list()
ticks <- list()
ticks$major <- seq(1980, 2015, by=5)
ticks$minor <- c(1979, 2018)

majorLength = 3 #input$length
minor_majorRatio = 0.7 #input$ratio


ggplot()+
  geom_step(
    data=dataSet1,
    mapping=
      aes(
        x=x,
        y=y
      )
  ) +
  scale_x_continuous(
    breaks={
      breaks = 
        c(1979,seq(1985, 2015, by=5),2018)
      breaks
      },
    labels={
      labels = c(
  "1979", "85", "90", "95", "2000", "05", "10", "15", "18"
)
      labels}
  ) +
  theme(
    axis.ticks.length.x = unit(0,"mm")
  ) +
  geom_rug(
    mapping=aes(
      x=ticks$major
      ),
    outside=TRUE, # draw rug outside the plot panel
    size=0.5, #input$majorsize
    length=grid::unit(
      majorLength, 
      "mm"
    )
  ) +
  geom_rug(
    mapping=aes(
      x=ticks$minor
    ),
    outside = TRUE,
    size=0.5, #input$minorsize
    length=grid::unit(
      minor_majorRatio*majorLength,
      "mm"
    )
  )+
  coord_cartesian(clip="off")+
  theme(
    axis.text.x = element_text(
      margin = margin(
        12 #input$margin
      ),
      size=16 #input$textSize
    ))

# the same as
ggplot()+
  geom_step(
    data=dataSet1,
    mapping=
      aes(
        x=x,
        y=y
      )
  ) +
{
  list(
    scale_x_continuous(
      breaks = {
        breaks <-
          c(1979, seq(1985, 2015, by = 5), 2018)
        breaks
      },
      labels = {
        labels <- c(
          "1979", "85", "90", "95", "2000", "05", "10", "15", "18"
        )
        labels
      }
    ),
    theme(
      axis.ticks.length.x = unit(0, "mm")
    ),
    geom_rug(
      mapping = aes(
        x = ticks$major
      ),
      outside = TRUE, # draw rug outside the plot panel
      size = 0.5, # input$majorsize
      length = grid::unit(
        majorLength,
        "mm"
      )
    ),
    geom_rug(
      mapping = aes(
        x = ticks$minor
      ),
      outside = TRUE,
      size = 0.5, # input$minorsize
      length = grid::unit(
        minor_majorRatio * majorLength,
        "mm"
      )
    ),
    coord_cartesian(clip = "off"),
    theme(
      axis.text.x = element_text(
        margin = margin(
          12 # input$margin
        ),
        size = 16 # input$textSize
      )
    )
  )
}


ggplot1$plot1


ggplot1$plot1  -> # allow drawing outside the plot panel 
  ggplot1$plot2

ggplot1$plot2

ggplot1$plot2 

Update econDV2 and .Rprofile

devtools::install_github("tpemartin/econDV2", force=T)

Then modify your .Rprofile file in your project. Locate gg <- list(...) change it to

gg <- list(
  dash = econDV2::ggdash,
  geom = econDV2::ggbrowse,
  aes = econDV2::ggaes,
  resize_image = econDV2::resize_image
)

2.1 Example

ggplot()+
  geom_point(
    mapping = aes(
      x=c(53, 56, 58),
      y=c(49, 54.9, 58)
    ),
    shape=21,
    color="black",
    stroke=1, #input$stroke
    fill="blue", #input$fill
    size=5 #input$size
  )

互動式資料視覺化時間調查

目前時間: 四 7~9

針對R語言中階使用者且有相當ggplot2程度使用者所設計的資料視覺化課程,本課程主要教授web app互動資訊儀表板的設計,課程目標有:

  1. 如何使用R進行前端web UI佈局,同時介紹兩個響應式前端框架(bootstrap, materialise)與R的揉合使用。
  2. 使用者端的互動式資料視覺化設計,從ggplot2的角度出發學習plotly.js互動圖形設計。
  3. 伺服器端的互動式資料視覺化設計,主要以Shiny為後端開發骨架,進一步帶入互動元素中常見的reactive programming概念。
  4. Web app deployment基本概念。

有要修的同學在以下可以的時段:

可以 按 thumb-up
不可以 按thumb-down

不打算修的不用回應。

Final Project

Due: Feb. 6
Format: Rmd file with 3 graphs. It's knitted result is like Daily Chart in Economist.

geom_rug as axis ticks.

breaks = c(
  1979,
  seq(1985, 2015, by=5),
  2018
)
labels = c(
  "1979", "85", "90", "95", "2000", "05", "10", "15", "18"
)
ggplot1 <- list()

ggplot()+
  geom_step(
    data=dataSet1,
    mapping=
      aes(
        x=x,
        y=y
      )
  ) -> ggplot1$plot0
ggplot1$plot0

x=interger
x=discrete
scale_x_discrete
scale_x_continuous

Fine tune x scale

ggplot1$plot0 +
  scale_x_continuous(
    breaks=breaks,
    labels=labels
  ) -> ggplot1$plot1

ggplot1$plot1
ggplot1$plot1 +
  theme(
    axis.ticks.length.x=unit(0, "mm")
  ) -> ggplot1$plot2

ggplot1$plot2
bigyears <- 
  seq(1980, 2015, by=5)
smallyears <-
  seq(1979, 2018)
ggplot1$plot2 +
  geom_rug(
    aes(
      x=bigyears
    ),
    outside = T,
    length=unit(
      2, #input$bigT
      "mm"
    )
  ) +
  geom_rug(
    aes(
      x=smallyears
    ),
    outside = T,
    length=unit(
      1, #input$smallT
      "mm"
    )
  )+
  coord_cartesian(clip="off")

4.7 Exercise 1

set.seed(2020)
type1 <- function(){
  dnorm(1990:2010, mean=1991, sd=3)*2500 -> x
    round(x, digits = 0)
}
type2 <- function(){
  dnorm(1994:2010, mean=1998, sd=2)*1000->x
  round(x, digits=0)
}
type3 <- function(){
  dnorm(2002:2010, mean=2005, sd=2.3)*800->x
  round(x, digits=0)
}

data_set4 <- data.frame(
  year=c(
    1990:2010,
    1994:2010,
    2002:2010),
  storage_type=
    c(
      rep("type1", 21),
      rep("type2", 17),
      rep("type3", 9)),
  sales_amount=c(
    type1(), 
    type2(),
    type3()
  )
)

Week 11 graph

The demo of post-image editing using Boxy SVG is what I am going to illustrate next week.
2019GDPExpenditureShareAsiaCompare

Week 18 Weekly Graph

This semester I will drop one weekly graph. So if you are too busy preparing your final, you can skip one graph without affecting your grades. But I still encourage to submit your last weekly graph so that I can give you some comments.

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.