Skip to content
Snippets Groups Projects
Verified Commit ffb47975 authored by ck85nori's avatar ck85nori :railway_track:
Browse files

adds plots with R

- new image sub-directory layout
- updates README instructions
parent 2ea2b478
No related branches found
No related tags found
No related merge requests found
Pipeline #284 passed
*.pdf *.pdf
img/*.svg img/graph/*.svg
img/plot/*.svg
csvautobooktabular
Graphviz
img
pandoc pandoc
results.csv
WatsonCrick1953 WatsonCrick1953
...@@ -4,22 +4,37 @@ Change to Document Title Here ...@@ -4,22 +4,37 @@ Change to Document Title Here
Building Building
-------- --------
Build the PDF: To build the PDF, just type `make`. Make already does incremental compilation,
i.e. it re-compiles only those targets whose sources changed. If you want to
watch for changes and automatically run `make` when something changes, use
[watchexec][]:
``` ```
make title.pdf watchexec make
``` ```
The `watchexec` tool honors `.gitignore`.
### Requirements ### Requirements
Required: These requirements are all more or less optional or replaceable. If you want to
build the template PDF, you need these dependencies:
- [git][]
- [pandoc and pandoc-citeproc][pandoc]
- LaTeX, either through **texlive** or **MiKTeX**
- GNU **make**
- [graphviz][]
- R including the packages **data.table**, **tidyverse** and **svglite**
- [watchexec][]
- [markdown-spellcheck][]
- [git](https://git-scm.com/downloads) **Note:** On MS Windows, it might be helpful using [chocolatey][].
- [pandoc, pandoc-citeproc](https://pandoc.org/installing.html)
- LaTeX, either texlive or MiKTeX
- make
Optional:
- [graphviz](https://graphviz.gitlab.io/download/) [chocolatey]: https://chocolatey.org/
- [watchexec](https://github.com/watchexec/watchexec/releases) [git]: https://git-scm.com/downloads
[graphviz]: https://graphviz.gitlab.io/download/
[markdown-spellcheck]: https://www.npmjs.com/package/markdown-spellcheck
[pandoc]: https://pandoc.org/installing.html
[watchexec]: https://github.com/watchexec/watchexec/releases
...@@ -14,6 +14,6 @@ You can automatically insert tables from your results if you store them in CSV. ...@@ -14,6 +14,6 @@ You can automatically insert tables from your results if you store them in CSV.
\begin{table} \begin{table}
\centering \centering
\csvautobooktabular{results.csv} \csvautobooktabular{img/plot/results.csv}
\caption{These are my super significant results.} \caption{These are my super significant results.}
\end{table} \end{table}
Discussion Discussion
========== ==========
You can add flow charts produced with Graphviz as in figure \ref{flowchart}.
Note how you inline the \LaTeX\ references.
![This is the image caption. This image shows how git remotes ![This is the image caption. This image shows how git remotes
work.](img/git-remote-commands.svg) work.\label{flowchart}](img/graph/git-remote-commands.svg)
See these awesome, auto-generated plot in figure \ref{plot}.
![The plot from the results data.\label{plot}](img/plot/results.svg)
SOURCES_DOT = $(wildcard *.dot) default: all
OBJECTS_DOT_SVG = $(SOURCES_DOT:.dot=.svg) all: subdirs
OBJECTS = \ SUBDIRS = \
$(OBJECTS_DOT_SVG) \ graph \
plot \
all: $(OBJECTS) $(SUBDIRS):
$(MAKE) -C $@
$(OBJECTS): subdirs: $(SUBDIRS)
%.svg: %.dot
dot -Tsvg -o $@ $<
clean: clean:
rm -f $(OBJECTS) @for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir $@; \
done
.PHONY: \ .PHONY: \
all \ all \
clean \ clean \
default \
subdirs \
$(SUBDIRS) \
SOURCES_DOT = $(wildcard *.dot)
OBJECTS_DOT_SVG = $(SOURCES_DOT:.dot=.svg)
OBJECTS = \
$(OBJECTS_DOT_SVG) \
all: $(OBJECTS)
$(OBJECTS):
%.svg: %.dot
dot -Tsvg -o $@ $<
clean:
rm -f $(OBJECTS)
.PHONY: \
all \
clean \
File moved
SOURCES_CSV = $(wildcard *.csv)
OBJECTS_CSV_SVG = $(SOURCES_CSV:.csv=.svg)
OBJECTS = \
$(OBJECTS_CSV_SVG) \
all: $(OBJECTS)
$(OBJECTS):
%.svg: %.csv
Rscript --vanilla $*.R
clean:
rm -f $(OBJECTS)
.PHONY: \
all \
clean \
library(data.table)
library(ggplot2)
data <- fread("results.csv")
plot <- ggplot(data, aes(x, y)) +
geom_point(aes(col = cat))
ggsave("results.svg", plot)
cat,x,y,foo
a,1,2,8
b,6,3,7
c,7,4,5
d,2,5,1
e,1,8,7
a,b,c
1,2,3
4,5,6
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment