Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add vertical lines? #54

Open
ignacio82 opened this issue Sep 18, 2015 · 4 comments
Open

add vertical lines? #54

ignacio82 opened this issue Sep 18, 2015 · 4 comments

Comments

@ignacio82
Copy link

Is it possible to add vertical lines to a graph? like geom_vline in ggplot2

Right now I have this graph:

df1 <-
  structure(
    list(
      Timestamp = structure(
        c(
          1441814593, 1441818193,
          1441821398, 1441821449, 1441828375, 1441873127, 1441813676, 1441837436,
          1441843661, 1441885583, 1441966341, 1441985621, 1442048926, 1442321691,
          1442321740, 1442328339, 1442329081, 1442349761, 1442391375, 1442408140,
          1442417679, 1442496854, 1442506500
        ), tzone = "UTC", class = c("POSIXct",
                                    "POSIXt")
      ), Group = c(
        1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
        2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L
      )
    ), .Names = c("Timestamp",
                  "Group"), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,-23L)
  ) %>% group_by(Group) %>% 
  arrange(Timestamp) %>% 
  mutate(count = row_number()) 

library(taucharts)
df1 %>% group_by(Group) %>% 
  arrange(Timestamp) %>% 
  mutate(count = row_number()) %>% 
  tauchart() %>% 
  tau_line("Timestamp", "count", "Group") %>% 
  tau_legend() %>% tau_tooltip() %>% 
  tau_guide_x(auto_scale=TRUE, label="Timestamp", tick_format="%b %d")

I would like to add two vertical lines:

vlines <- as.numeric(c(
  as.POSIXct("2015-09-11 00:00:00"),
  as.POSIXct("2015-09-15 00:00:00")
))   

Is that possible?

Thanks!

@smach
Copy link

smach commented Mar 8, 2016

+1 -- would love to add a horizontal line, too!

@jeremiahpslewis
Copy link
Contributor

Hey! This functionality (horizontal and vertical lines) is currently provided with the annotations plugin. Unfortunately until #64 is solved, there isn't an easy way to produce anything but dotted lines.

Hope this helps!
/j

data <- data.frame(date = seq(Sys.Date(), Sys.Date() - 9, length.out = 10), revenue = rpois(10, 50))
tauchart(data) %>%
  tau_point("date", "revenue") %>%
  tau_guide_x(tick_format = "%d.%m") %>%
  tau_annotations(data.frame(dim = "date", val = data$date,
                             text = "Another day", position = "front",
                             color = '#4300FF'))

@smach
Copy link

smach commented Mar 8, 2016

Thanks very much. Your example making multiple lines works well for me. FYI this code in the tau_annotations help file does not appear to be adding one single line to each plot (at least for me):

data(cars_data)
tauchart(cars_data) %>%
  tau_point("milespergallon", c("class", "price"), color="class") %>%
  tau_annotations(data.frame(dim = "y", val = 50000,
       text = "Whoa there!", position = "front",
       color = '#4300FF'))

@jeremiahpslewis
Copy link
Contributor

I know, sorry! It's fixed in this pull request: #67 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants