Skip to content

Commit

Permalink
updated figure captions
Browse files Browse the repository at this point in the history
Former-commit-id: 71f2417
  • Loading branch information
Robinlovelace committed Jun 22, 2014
1 parent 84f270f commit 2151dde
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 19 deletions.
Binary file added figure/Adding world lines ggplot2 style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure/Beautifying.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure/Plotting great circles 1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure/Plotting points.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure/Plotting segments.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure/ggplot world 1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure/ggplot2 projections1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure/ggplot2 projections2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure/polygon paths ggplo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figure/unnamed-chunk-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions vignettes/world-great-circles.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ lapply(x, require, character.only = T)
Let us proceed by loading an entire map of the world from
the **rworldmap** function `getMap`:

```{r, fig.keep='none'}
```{r Basic plot, fig.keep='none'}
s <- getMap() # load the map data
class(s) # what type of are we dealing with?
nrow(s) # n. polygons
Expand All @@ -59,7 +59,7 @@ over the surface of the earth in terms of longitude. Note the use of
which have a much lower surface area than the equator, per
[line of longitude](http://en.wikipedia.org/wiki/Cylindrical_equal-area_projection).

```{r}
```{r Plotting points}
set.seed(1984)
n = 20
x <- runif(n=n, min=bbox(s)[1,1], max = bbox(s)[1,2] )
Expand All @@ -77,7 +77,7 @@ So how to join these randomly scattered points on the planet?
A first approximation would be to join them with straight lines.
Let's join point 1, for example, to all others to test this method:

```{r}
```{r Plotting segments}
plot(s)
segments(x0 = rep(coordinates(p[1,])[1], n), y0 = rep(coordinates(p[1,])[2], n),
x1 = coordinates(p)[,1], y1 = coordinates(p)[,2])
Expand All @@ -91,7 +91,7 @@ lines over the Earth's surface: these are not the shortest,
[great circle](http://en.wikipedia.org/wiki/Great_circle) lines.
To add these great circle lines, we must use the **geosphere** package:

```{r}
```{r Plotting great circles 1}
head(gcIntermediate(p[1,], p[2]), 2) # take a look at the output of the gcIntermediate function
plot(s)
lines(gcIntermediate(p[1,], p[2,]), col = "blue", lwd = 3)
Expand All @@ -112,7 +112,7 @@ The maps we created so far are not exactly beautiful.
Let's try to make the map look a little nicer:


```{r}
```{r Beautifying}
names(s@data)
library(rgdal)
# s <- spTransform(s, CRSobj=CRS("+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))
Expand All @@ -133,7 +133,7 @@ The 'beautified' map above certainly is more interesting visually, with added
colours. But it's difficult to call it truly beautiful. For that, as with
so many things in R plotting, we turn to ggplot2.

```{r}
```{r ggplot world 1}
s <- map_data("world")
m <- ggplot(s, aes(x=long, y=lat, group=group)) +
geom_polygon(fill="green", colour="black")
Expand All @@ -145,7 +145,7 @@ based solely on origins and destinations, this works fine, but
as with the previous example, generates incorrect
shortest path lines:

```{r}
```{r Adding world lines ggplot2 style}
# adding lines
# for all combinations of lines, use this code
# p1 <- do.call(rbind, rep(list(coordinates(p)),n ))
Expand Down Expand Up @@ -175,7 +175,7 @@ To create the for loop, first create a data frame of a single line.
The iterate for all zones and use `rbind` to place one data frame on
top of the next:

```{r}
```{r ggpaths}
paths <- gcIntermediate(p[5,], p[1,])
paths <- data.frame(paths)
paths$group <- 1
Expand All @@ -196,7 +196,7 @@ Note the use of the command `ggplot()`, which initiates an
empty ggplot2 instances, ready to be filled with layers.
This is more flexible than stating the data at the outset.

```{r}
```{r polygon paths ggplo2}
ggplot() + geom_polygon(data = s, aes(x=long, y=lat, group=group),
fill = "green", colour="black") +
geom_path(data = paths, aes(lon, lat , group = group)) +
Expand All @@ -213,7 +213,7 @@ e.g. by using `spTransform`). However,
as shown in the examples below, the library is currently buggy
for plotting polygons.

```{r}
```{r ggplot2 projections}
# to see the range of projections available using this method, try ?mapproject
m <- last_plot()
m + coord_map()
Expand Down
18 changes: 9 additions & 9 deletions vignettes/world-great-circles.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ plot(s)
points(p, col = "red")
```

![plot of chunk unnamed-chunk-3](figure/unnamed-chunk-3.png)
![plot of chunk Plotting points](figure/Plotting points.png)

## Joining the dots

Expand All @@ -122,7 +122,7 @@ segments(x0 = rep(coordinates(p[1,])[1], n), y0 = rep(coordinates(p[1,])[2], n),
x1 = coordinates(p)[,1], y1 = coordinates(p)[,2])
```

![plot of chunk unnamed-chunk-4](figure/unnamed-chunk-4.png)
![plot of chunk Plotting segments](figure/Plotting segments.png)

(Incidentally, isn't the use of `segments` here rather clunky - any suggestions
of a more elegant way to do this welcome.)
Expand Down Expand Up @@ -153,7 +153,7 @@ for(i in 1:length(p)){
}
```

![plot of chunk unnamed-chunk-5](figure/unnamed-chunk-5.png)
![plot of chunk Plotting great circles 1](figure/Plotting great circles 1.png)

Fantastic. Now we have great circle lines represented on a
map with a [geographic coordinate system (CRS)](http://en.wikipedia.org/wiki/Geographic_coordinate_system)
Expand Down Expand Up @@ -199,7 +199,7 @@ for(i in 1:length(p)){
}
```

![plot of chunk unnamed-chunk-6](figure/unnamed-chunk-6.png)
![plot of chunk Beautifying](figure/Beautifying.png)

```r
par(bg = 'white')
Expand All @@ -219,7 +219,7 @@ m <- ggplot(s, aes(x=long, y=lat, group=group)) +
m
```

![plot of chunk unnamed-chunk-7](figure/unnamed-chunk-7.png)
![plot of chunk ggplot world 1](figure/ggplot world 1.png)

When we add the lines in projected maps (i.e. with a Euclidean coordinate system)
based solely on origins and destinations, this works fine, but
Expand All @@ -245,7 +245,7 @@ ggplot() + geom_polygon(data = s,aes(x=long, y=lat, group=group),
geom_segment(aes(x = p1[,1], y = p1[,2], xend = p2[,1], yend = p2[,2]))
```

![plot of chunk unnamed-chunk-8](figure/unnamed-chunk-8.png)
![plot of chunk Adding world lines ggplot2 style](figure/Adding world lines ggplot2 style.png)

## Adding great circle lines to ggplot2 maps

Expand Down Expand Up @@ -289,7 +289,7 @@ ggplot() + geom_polygon(data = s, aes(x=long, y=lat, group=group),
theme(panel.background = element_rect(fill = 'lightblue'))
```

![plot of chunk unnamed-chunk-10](figure/unnamed-chunk-10.png)
![plot of chunk polygon paths ggplo2](figure/polygon paths ggplo2.png)

## Changing projection in ggplot

Expand All @@ -308,7 +308,7 @@ m <- last_plot()
m + coord_map()
```

![plot of chunk unnamed-chunk-11](figure/unnamed-chunk-111.png)
![plot of chunk ggplot2 projections](figure/ggplot2 projections1.png)

```r
# remove fill as this clearly causes problems:
Expand All @@ -319,7 +319,7 @@ m <- ggplot() + geom_path(data = s, aes(x=long, y=lat, group=group), colour="bla
m + coord_map("ortho", orientation=c(41, -74, 0)) # for ortho maps
```

![plot of chunk unnamed-chunk-11](figure/unnamed-chunk-112.png)
![plot of chunk ggplot2 projections](figure/ggplot2 projections2.png)

## Conclusion

Expand Down

0 comments on commit 2151dde

Please sign in to comment.