hafen / trelliscopejs

TrelliscopeJS R Package
https://hafen.github.io/trelliscopejs
Other
263 stars 37 forks source link

Better examples of how you export a Trelliscope object #24

Open abresler opened 7 years ago

abresler commented 7 years ago

Could you better outline how to save and publish a trelliscop object outside of publishing it to rpubs. Going through the docs but can't figure out how to do it.

hafen commented 7 years ago

Sure. The output that is written when you make the plot works standalone and can be put on a web server or github pages, zipped up and sent to someone else, etc.

For example,

library(gapminder)
library(ggplot2)
library(gapminder)

qplot(year, lifeExp, data = gapminder) +
  xlim(1948, 2011) + ylim(10, 95) + theme_bw() +
  facet_trelliscope(~ country + continent, nrow = 2, ncol = 7, width = 300, path = "/tmp/gap")

list.files("/tmp/gap")
[1] "appfiles"   "index.html" "lib" 

The contents of /tmp/gap is publishable anywhere.

abresler commented 7 years ago

Fantastic thanks so much for clarifying!!


Alex Bresler abresler@asbcllc.com

​www.asbcllc.com​

917-455-0239 (cell)

On Feb 2, 2017 2:05 AM, "hafen" notifications@github.com wrote:

Sure. The output that is written when you make the plot works standalone and can be put on a web server or github pages, zipped up and sent to someone else, etc.

For example,

library(gapminder) library(ggplot2) library(gapminder)

qplot(year, lifeExp, data = gapminder) + xlim(1948, 2011) + ylim(10, 95) + theme_bw() + facet_trelliscope(~ country + continent, nrow = 2, ncol = 7, width = 300, path = "/tmp/gap")

list.files("/tmp/gap")

[1] "appfiles" "index.html" "lib"

The contents of /tmp/gap is publishable anywhere.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hafen/trelliscopejs/issues/24#issuecomment-276883861, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtM1DIrXQKk_Gnb-Bzy2_7FMNCNshRbks5rYYAvgaJpZM4L0FO8 .

hafen commented 7 years ago

Sure. I'll leave this open until I update the docs.

jimjam-slam commented 6 years ago

Out of interest, will the files still be written out to path even if it isn't possible to open the page, or will it just fail? I do a lot of remote work that is queued up on a PBS system, and while I could use rmote to open a trelliscope display on my remote server, I can't do that if I'm running a script. It would be great if I can just do the write-out without the display being opened.

(I mean, I'd probably move to more of an RMarkdown workflow in future anyway, but this would be sort of a half-step from my current workflow, where I write a bunch of files out and scp them over!)

mnneely commented 1 year ago

Old conversation I know, but I couldn't find any updates. I see how this works if you are using ggplot2, but how would you export d below to an image? The example is a modified version of one in the help documentation for trelliscopejs::trelliscope. I have other plots that exceed the capability of ggplotly() so I was hoping for a solution that does not involve ggplot2. Thanks in advance.

library(tidyverse)
library(plotly)
library(trelliscopejs)

d <- mpg %>%
  nest(data = !one_of(c("manufacturer", "class"))) %>%
  mutate(
    mean_city_mpg = map_dbl(data, ~ mean(.$cty)),
    panel = map_plot(data, function(x) {
      plot_ly(data = x, x = ~cty, y = ~hwy,
              type = "scatter", mode = "markers")
    })
  ) %>% trelliscope(name = "city_vs_highway_mpg", nrow = 3, ncol = 3)
hafen commented 1 year ago

I've been working on a new version of Trelliscope. Can you take a look here: https://trelliscope.org/trelliscope/articles/trelliscope.html and here: https://trelliscope.org/trelliscope/articles/panels.html and see if these docs help get you what you need using the new package? Basically anything you can generate that would go in a or