Last active
October 30, 2023 21:42
-
-
Save andrewheiss/4ece621813a27dfdcaef7f1c2d773237 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "tikz in Quarto!" | |
format: html | |
--- | |
```{r include=FALSE} | |
# Necessary for using dvisvgm on macOS | |
# See https://www.andrewheiss.com/blog/2021/08/27/tikz-knitr-html-svg-fun/ | |
Sys.setenv(LIBGS = "/usr/local/share/ghostscript/9.53.3/lib/libgs.dylib.9.53") | |
font_opts <- list(dvisvgm.opts = "--font-format=woff") | |
``` | |
```{tikz complete-pooling, engine.opts=font_opts} | |
#| echo: false | |
#| fig-cap: "Complete pooling" | |
#| fig-align: center | |
#| fig-ext: svg | |
#| out-width: 100% | |
\usetikzlibrary{positioning} | |
\usetikzlibrary{shapes.geometric} | |
\begin{tikzpicture}[{every node/.append style}=draw] | |
\node [rectangle] (pop) at (0, 4) {Population}; | |
\node [ellipse] (y1) at (-5, 2.5) {$y_1$}; | |
\node [ellipse] (y2) at (-3, 2.5) {$y_2$}; | |
\node [ellipse] (y3) at (-1, 2.5) {$y_3$}; | |
\node [ellipse] (y4) at (1, 2.5) {$y_4$}; | |
\node [ellipse, draw=white] (ydots) at (3, 2.5) {$\dots$}; | |
\node [ellipse] (yn) at (5, 2.5) {$y_n$}; | |
\draw [-latex] (pop) to (y1); | |
\draw [-latex] (pop) to (y2); | |
\draw [-latex] (pop) to (y3); | |
\draw [-latex] (pop) to (y4); | |
\draw [-latex, dashed] (pop) to (ydots); | |
\draw [-latex] (pop) to (yn); | |
\end{tikzpicture} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice gist, any idea on the use of$\LaTeX$ document it is straightforward to include in the headers but for HTML output I do not know
pgfplots
package? like the examples here. For a