diff --git a/content/articles/2021-07-23-our-new-digital-home/index.Rmd b/content/articles/2021-07-23-our-new-digital-home/index.Rmd index e867391bb0b5213747eeaf08317f7aa7cceefbb1..26ccb379a660d3fef2da139cd87d6282fa6de672 100644 --- a/content/articles/2021-07-23-our-new-digital-home/index.Rmd +++ b/content/articles/2021-07-23-our-new-digital-home/index.Rmd @@ -8,6 +8,7 @@ math: katex pseudocode: true --- + We are finally live at CleverThis.com and I wanted to make a first post just to show off some of the new sites awesome formatting features. <!--more--> @@ -86,7 +87,7 @@ fooBar(7); if(5 > foo) { farBoo(foo, 7, "jeff"); } -{{</highlight>}} +{{< /highlight >}} or with backticks @@ -146,7 +147,8 @@ ggplot(datasaurus_dozen, aes(x=x, y=y))+ ease_aes('cubic-in-out') ``` -or using animate library +or using animate library... + ```{r, animation.hook="gifski", fig.show='animate'} library(animation) @@ -156,6 +158,97 @@ xx = grad.desc(f1, pi * c(-2, -2, 2, 2), c(-2 * pi, 2)) xx$persp(col = "lightblue", theta = 30, phi = 30) ``` +Or with plotly, first ggplot... + +```{r, message=FALSE} +library(dplyr) +library(tidyr) +library(DT) +library(ggplot2) +library(plotly) +anscombe_tidy <- anscombe %>% + mutate(observation = seq_along(x1)) %>% + gather(key, value, -observation) %>% + separate(key, c("variable", "set"), 1, convert = TRUE) %>% + mutate(set = as.character(as.roman(set))) %>% + spread(variable, value) %>% + arrange(set) +head(anscombe_tidy) + +cols <- c("#0072B2", "#009E73", "#D55E00", "#CC79A7") +ans_plot <- ggplot(anscombe_tidy, aes(x, y, colour = set)) + + geom_point(size = 3, alpha = .7) + + geom_smooth(method = "lm", se = FALSE) + + facet_wrap(~ set) + + theme_bw() + + theme(legend.position="none") + + scale_colour_manual(values = cols) + +ans_plot +``` + +now plotly (need to use noescape, see code)... + +```r +ggplotly(ans_plot) +``` + +{{< noescape >}} +```{r, message=FALSE, echo=FALSE} +ggplotly(ans_plot) +``` +{{< /noescape >}} + +Another example using plot_ly: + +```r +library(plotly) +library(gapminder) +p <- gapminder %>% + plot_ly( + x = ~gdpPercap, + y = ~lifeExp, + size = ~pop, + color = ~continent, + frame = ~year, + text = ~country, + hoverinfo = "text", + type = 'scatter', + mode = 'markers' + ) %>% + layout( + xaxis = list( + type = "log" + ) + ) +p +``` + +{{< noescape >}} +```{r, echo=FALSE, message=FALSE, warning=FALSE} +library(plotly) +library(gapminder) +p <- gapminder %>% + plot_ly( + x = ~gdpPercap, + y = ~lifeExp, + size = ~pop, + color = ~continent, + frame = ~year, + text = ~country, + hoverinfo = "text", + type = 'scatter', + mode = 'markers' + ) %>% + layout( + xaxis = list( + type = "log" + ) + ) +p +``` +{{< /noescape >}} + ## Block quotes Nothing too special about blockquotes, or as Abe Lincoln said... diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 888f7a0a4d897e45574fbdc1cdea9a04c5be8d72..fc25d363e1d8e22aa3173a4c6fb2a1a73de74123 100755 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -47,6 +47,19 @@ $K.dom(window).on('load', $K.init); </script> +{{ if or (eq .Params.math "katex") (eq .Site.Params.math "katex") }} + {{ partial "math-katex.html" .}} +{{ else if or (eq .Params.math "mathjax") (eq .Site.Params.math "mathjax") }} + {{ partial "math-mathjax.html" .}} +{{ end }} + +{{ if or (eq .Params.pseudocode true) (eq .Site.Params.pseudocode true) }} + {{ if not (or (eq .Params.math "mathjax") (eq .Site.Params.math "mathjax")) }} + {{ partial "math-mathjax.html" .}} + {{ end }} + {{ partial "pseudocode.html" .}} +{{ end }} + {{ if or (eq .Params.pseudocode true) (eq .Site.Params.pseudocode true) }} -{{ partial "pseudocode-rewrite.html" .}} + {{ partial "pseudocode-rewrite.html" .}} {{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 4f335076b8b1265c229319a02867edf0106c3b07..252f0631879ce81ba2eb418cef5f23e845cbb9bd 100755 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -26,18 +26,8 @@ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hack-font@3/build/web/hack-subset.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/academicons/1.8.0/css/academicons.min.css"> <link href="{{ $asset_base }}assets/fonts/fontawesome/css/all.css" rel="stylesheet"> - {{ if or (eq .Params.math "katex") (eq .Site.Params.math "katex") }} - {{ partial "math-katex.html" .}} - {{ else if or (eq .Params.math "mathjax") (eq .Site.Params.math "mathjax") }} - {{ partial "math-mathjax.html" .}} - {{ end }} - {{ if or (eq .Params.pseudocode true) (eq .Site.Params.pseudocode true) }} - {{ if not (or (eq .Params.math "mathjax") (eq .Site.Params.math "mathjax")) }} - {{ partial "math-mathjax.html" .}} - {{ end }} - {{ partial "pseudocode.html" .}} - {{ end }} + <!-- Icons --> <link rel="apple-touch-icon" sizes="180x180" href="{{ $asset_base }}assets/apple-touch-icon.png"> <link rel="icon" type="image/png" sizes="32x32" href="{{ $asset_base }}assets/favicon-32x32.png"> diff --git a/layouts/shortcodes/noescape.html b/layouts/shortcodes/noescape.html new file mode 100644 index 0000000000000000000000000000000000000000..e4edf661c260f817e58625fe2b02e43626cb952c --- /dev/null +++ b/layouts/shortcodes/noescape.html @@ -0,0 +1 @@ +{{ .Inner | safeHTML }}