Commit 54b6968f authored by Lucas Mello Schnorr's avatar Lucas Mello Schnorr
Browse files

a tentative of doing a plot with ggplot2

parent b03d3f5f
......@@ -70,7 +70,12 @@ loaded via a namespace (and not attached):
FILE <- "data/f3/3a9852-afa9-4cda-b9e8-34b1f2dfe368/positions.zip"
unzip(FILE)
read_delim("positions.txt", delim=" ", col_names=FALSE) %>%
rename(Track = X1)
rename(Track = X1,
Time = X2,
X = X3,
Y = X4,
Z = X5) %>%
print -> df.exp0
#+end_src
#+RESULTS:
......@@ -85,7 +90,7 @@ cols(
X5 = col_double()
)
# A tibble: 109,900 x 5
Track X2 X3 X4 X5
Track Time X Y Z
<dbl> <dbl> <dbl> <dbl> <dbl>
 1 0 0 -0.0000773 0.00170 0.195
 2 0 0.0001 0.0000994 0.00165 0.195
......@@ -100,6 +105,43 @@ cols(
# … with 109,890 more rows
#+end_example
** Plot
See here
https://stackoverflow.com/questions/6862742/draw-a-circle-with-ggplot2
on how to draw a circle.
#+begin_src R :results output graphics :file img/positions.png :exports both :width 600 :height 600 :session
circleFun <- function(center = c(0,0),diameter = 1, npoints = 100){
r = diameter / 2
tt <- seq(0,2*pi,length.out = npoints)
xx <- center[1] + r * cos(tt)
yy <- center[2] + r * sin(tt)
return(data.frame(x = xx, y = yy))
}
df.tpc.outer <- circleFun(c(0,0), 4.95, npoints = 100)
df.tpc.inner <- circleFun(c(0,0), 1.80, npoints = 100)
df.exp0 %>%
ggplot(aes(x=X, y=Y)) +
# Draw the tracks
geom_point(aes(color=as.factor(Track)), size=.1) +
# Draw approximate TPC
geom_path(data=df.tpc.outer, aes(x=x, y=y)) +
geom_path(data=df.tpc.inner, aes(x=x, y=y)) +
# Cosmetics
theme_bw(base_size=16) +
theme(legend.position="none",
axis.title=element_blank(),
axis.text=element_blank(),
axis.ticks=element_blank())
#+end_src
#+RESULTS:
[[file:img/positions.png]]
*
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment