From a7e7ac8a2a1d6bc572f08b01ca646756e64371f8 Mon Sep 17 00:00:00 2001 From: hughjonesd Date: Thu, 8 Feb 2024 23:11:10 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20hughjone?= =?UTF-8?q?sd/ggmagnify@dbac174d05c3942771745db35f85ed2f955cb9d4=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apple-touch-icon-120x120.png | Bin 8788 -> 8788 bytes apple-touch-icon-152x152.png | Bin 11650 -> 11650 bytes apple-touch-icon-180x180.png | Bin 14234 -> 14234 bytes apple-touch-icon-60x60.png | Bin 3800 -> 3800 bytes apple-touch-icon-76x76.png | Bin 4848 -> 4848 bytes apple-touch-icon.png | Bin 14234 -> 14234 bytes favicon-16x16.png | Bin 1209 -> 1209 bytes favicon-32x32.png | Bin 2054 -> 2054 bytes index.html | 65 ++++++++++-------- news/index.html | 10 ++- pkgdown.yml | 2 +- .../README-example-and-so-ad-infinitum-1.png | Bin 369277 -> 369057 bytes .../figures/README-example-corners-1.png | Bin 0 -> 121609 bytes .../README-example-magnify-twice-1.png | Bin 339077 -> 338946 bytes .../figures/README-example-outline-1.png | Bin 72037 -> 70958 bytes .../figures/README-example-recompute-1.png | Bin 61683 -> 61540 bytes .../figures/README-example-recompute-2.png | Bin 63754 -> 63182 bytes reference/geom_magnify.html | 8 +++ search.json | 2 +- 19 files changed, 54 insertions(+), 33 deletions(-) create mode 100644 reference/figures/README-example-corners-1.png diff --git a/apple-touch-icon-120x120.png b/apple-touch-icon-120x120.png index 6359467ada7db0716ea939436f1642963766dc12..7665a3435df5fcce4adef181ad61321730898192 100644 GIT binary patch delta 97 zcmccOa>ZprB_|VyIG3uT>A@cxo1_&zjC2hwLX3>93=OP|&9w~-tPBhqXDBr>Ffgc= kxJHzuB$lLF<>sekrd2W+85o)98eq}z;pi;8$xjvY0cb@Wq5uE@ delta 97 zcmccOa>ZprB`2f2xIXj5rHvvRo1_&z40VkSLyU~AOw6qejI|96tPBiXQ&M*^Ffgc= kxJHzuB$lLF<>sekrd2W+85o)98eq|2VtJQs@>9ip093piK>z>% diff --git a/apple-touch-icon-152x152.png b/apple-touch-icon-152x152.png index 5cd29407cc7b720e43ac8d1f68139618f19a2d91..98d64603d94f7721e88a7b3572265e99c729919f 100644 GIT binary patch delta 97 zcmZpQZi=2z$;rea&ZU0ddcl>AO`bX)M!E(TAx6elh6Yx~mf8jeRt5$amq*@bU|>)! kag8WRNi0dV%FR#7OsixtGB7gHHNc`_!LNtOlZAEj0jIAWSO5S3 delta 97 zcmZpQZi=2z$;l`$uFqO=Ohs{Hlc$b{p{}uEh>@|CiMf@5skVWEm4SiUmVgEZ1_sp< k*NBpo#FA92-29Zxv`Pje10xe%11uWCU%s%JEUcRk03u=<@&Et; diff --git a/apple-touch-icon-180x180.png b/apple-touch-icon-180x180.png index c7759b273a433b5f95dffa306b23fea0ac534381..c2498a9ac4e5d36fcaa44dc138b7b6fd10c3bf07 100644 GIT binary patch delta 76 zcmbQ0KP!JiB_|VyIG09z%U;)wO^IgWM!E(TAx6elh6Yw92HFM&Rt5%szeGhR|1y)p OCTG8V?aIm8=J^0yVHN-Y delta 76 zcmbQ0KP!JiB`2f2xIWv%^QE&lHYJ*g8|oSxh8P)JnV4G{m}wgrSQ!|I$9Tz3{$(bG OO)ib`)56Kx=J^1Ec@`)D diff --git a/apple-touch-icon-60x60.png b/apple-touch-icon-60x60.png index 1c35d37e837cc92188420c51dfafbd59496e0027..b44560f910d58419631dc87116f8bb78d9654667 100644 GIT binary patch delta 97 zcmca1dqZ|YB_|VyIG3VY1na|%P4js@jC2hwLX3>93=OP|jkOI7tPBiFud_{LU|>)! kag8WRNi0dV%FR#7OsixtGB7gHHNc{QrE8z=!C8<`q`6-!cl?+A(MkcxjSTwL+JU)AJCSN`Pc!eAQ diff --git a/apple-touch-icon-76x76.png b/apple-touch-icon-76x76.png index 70d0d37bc96eb30a279f053b1f63a8b407c069a4..305a1b02ddd4a12de14f1bc61dee878637402d44 100644 GIT binary patch delta 76 zcmeyM`ayLvSQ!|Iu^X?R93Uix OO)fpETYPe(P(A=zM-<5b delta 76 zcmeyM`ayL93=OPIjI<35tPBiprn1;f{$(bG OO>Tw7o`%WV=J^1GB^HeU delta 76 zcmbQ0KP!JiB`2f2xIPD4dBmKJO^IgWhPuXvAx6elCgxTK7TN{|Rt5&{$%YP-f0;>P OlQXmH{4-hGJRbl!pcNkg diff --git a/favicon-16x16.png b/favicon-16x16.png index 7c6f2063db8600c3b499e4a27ec80d8a50acbedb..85b5a005915ba4bb6e9859d930c21b303d1c92b4 100644 GIT binary patch delta 99 zcmdnVxs!9l6(&w54sk9+>-VCqo9{BIGI|*48d!uF8Cw||SeaOA8yHv_7~D<@IL5%h mpjzS@QIe8al4_NkpOTqY$zWt)WTI<;MZ+rl7gdwJSn>gXvK$`( delta 99 zcmdnVxs!9l6(&wbd2xNd_ac8+ZobQ;%IIOJYit-|WNc+(Ze?hqZD3$!VBnJ(y^4W> mLAAs+q9i4;B-JW6KP5A*lEKKp$VArwiw0Yh$6}McSn>g@Asd_k diff --git a/favicon-32x32.png b/favicon-32x32.png index a9d2e425b99e52c9a220769a9c024dd2760afd8c..4ea36ef4b8d09f9dc518f867f8ecc3dd1a43840e 100644 GIT binary patch delta 97 zcmZn@XcL%F$;rea&SiY{VadvkO=sCWjC2hwLX3>93=OPI4YdsntPBiP)aC3M7#LJb kTq844X|hkty44X|jK?fhcV

ggmagnify creates a magnified inset of part of a ggplot object. Borders can be drawn around the target area and the inset, along with projection lines from one to the other. The inset can have a drop shadow. The magnified area can be a rectangle, an ellipse, a convex hull of points, or an arbitrary shape.

-

You can install the development version of ggmagnify from GitHub with:

+

You can install ggmagnify from r-universe:

-# install.packages("remotes")
-remotes::install_github("hughjonesd/ggmagnify")
-

Alternatively, install ggmagnify from r-universe:

-
 install.packages("ggmagnify", repos = c("https://hughjonesd.r-universe.dev", 
                  "https://cloud.r-project.org"))

This will install the latest github release (currently 0.2.0).

+

Or install the development version from GitHub with:

+
+# install.packages("remotes")
+remotes::install_github("hughjonesd/ggmagnify")

Basic inset

-

To create an inset, use geom_magnify(from, to). from can be a list giving the four corners of the area to magnify: from = c(xmin, xmax, ymin, ymax). Optionally you can use the names xmin, etc.

+

To create an inset, use geom_magnify(from, to). from can be a vector giving the four corners of the area to magnify: from = c(xmin, xmax, ymin, ymax).

Similarly, to specifies where the magnified inset should go: to = c(xmin, xmax, ymin, ymax).

 library(ggplot2)
@@ -107,7 +107,7 @@ 

Basic insetfrom <- c(xmin = 9.75e7, xmax = 9.95e7, ymin = 16, ymax = 28) # Names xmin, xmax, ymin, ymax are optional: -to <- c(2e08 - 2e7, 2e08 + 2e7,10, 26) +to <- c(2e8 - 2e7, 2e8 + 2e7,10, 26) ggp + geom_magnify(from = from, to = to)

@@ -125,10 +125,19 @@

Inset with shadow

+

Rounded corners +

+

New in version 0.3.0, use corners to give a proportional radius for rounded corners.

+
+ggp + geom_magnify(from = from, to = to, 
+                   corners = 0.1, shadow = TRUE)
+

+
+

Ellipse

This requires R 4.1 or higher, and an appropriate graphics device.

-
+
 
 ggp + geom_magnify(from = from, to = to, 
                    shape = "ellipse", shadow = TRUE)
@@ -138,7 +147,7 @@

EllipsePick points to magnify

To choose points to magnify, map from in an aes():

-
+
 ggpi <- ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) +
               geom_point() + xlim(c(1.5, 6))
 
@@ -149,7 +158,7 @@ 

Pick points to magnify

Faceting

-
+
 
 ggpi +
   facet_wrap(vars(Species)) +
@@ -162,7 +171,7 @@ 

FacetingMagnify an arbitrary region (experimental)

Use shape = "outline" to magnify the convex hull of a set of points:

-
+
 
 library(dplyr)
 
@@ -192,7 +201,7 @@ 

Magnify an arbitrary region (e #> Warning: Removed 1 rows containing missing values (`geom_point()`).

Use a grob or data frame to magnify any shape:

-
+
 
 s <- seq(0, 2*pi, length = 7)
 hex <- data.frame(x = 3 + sin(s)/2, y = 6 + cos(s)/2) 
@@ -205,7 +214,7 @@ 

Magnify an arbitrary region (e

Maps (experimental)

With maps, shape = "outline" magnifies just the selected map polygons:

-
+
 
 usa <- sf::st_as_sf(maps::map("state", fill=TRUE, plot =FALSE))
 
@@ -227,7 +236,7 @@ 

Maps (experimental)

Axes

-
+
 
 ggp + 
   scale_x_continuous(labels = NULL) + 
@@ -241,7 +250,7 @@ 

Projection lines and borders

Colour and linetype

-
+
 
 ggp + 
   geom_magnify(from = from, to = to,
@@ -251,7 +260,7 @@ 

Colour and linetype

Projection line styles

-
+
 
 ggpi <- ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) +
               geom_point()
@@ -262,13 +271,13 @@ 

Projection line styles geom_magnify(from = from2, to = to2, proj = "facing") # the default

-
+
 
 ggpi + 
   geom_magnify(from = from2, to = to2,
                proj = "corresponding") # always project corner to corner

-
+
 
 ggpi + 
   geom_magnify(from = from2, to = to2,
@@ -288,7 +297,7 @@ 

Graphics devicesAdding layers to the inset

geom_magnify() stores the plot when it is added to it. So, order matters:

-
+
 
 ggpi <- ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) +
               geom_point() + xlim(2, 6)
@@ -301,7 +310,7 @@ 

Adding layers to the inset#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x' #> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

-
+
 

For complex modifications to the inset, set plot explicitly:

-
+
 
 booms <- ggplot(faithfuld, aes(waiting, eruptions)) +
          geom_contour_filled(aes(z = density), bins = 50) +
@@ -337,7 +346,7 @@ 

Adding layers to the inset

Draw an inset outside the plot region

-
+
 
 ggp + 
   coord_cartesian(clip = "off") + 
@@ -350,7 +359,7 @@ 

Draw an inset outside the plot re

Keep grid lines the same

To make sure the inset uses the same grid lines as the main graph, set breaks in scale_x and scale_y:

-
+
 
 ggp2 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) + 
         geom_point() +
@@ -363,7 +372,7 @@ 

Keep grid lines the same geom_magnify(from = c(2.45, 3.05, 5.9, 6.6), to = c(3.4, 4.4, 5.5, 6.6), shadow = TRUE)

-
+
 
 # fix the grid lines:
 ggp2 +
@@ -377,7 +386,7 @@ 

Keep grid lines the sameRecomputing data

Use recompute if you want to recompute smoothers, densities, etc. in the inset.

-
+
  
 df <- data.frame(x = seq(-5, 5, length = 500), y = 0)
 df$y[abs(df$x) < 1] <- sin(df$x[abs(df$x) < 1])
@@ -392,7 +401,7 @@ 

Recomputing dataggp2 + geom_magnify(from = c(-1.25, 1.25, -1, 1), to = c(2, 5, 1, 5))

-
+
 
 # Recomputing recalculates the smooth for the inset:
 ggp2 + geom_magnify(from = c(-1.25, 1.25, -1, 1),
@@ -403,7 +412,7 @@ 

Recomputing data

Magnify twice

-
+
 
 data <- data.frame(
   x = runif(4000), 
@@ -423,7 +432,7 @@ 

Magnify twice= 0, colour ="white", proj.linetype = 1)

An inset within an inset is a bit more complex, but also doable:

-
+
 
 ggp <- data.frame(x = rnorm(1e5), y = rnorm(1e5), 
                   colour = sample(8L, 1e5, replace = TRUE)) |> 
diff --git a/news/index.html b/news/index.html
index 9736287..dd427fd 100644
--- a/news/index.html
+++ b/news/index.html
@@ -44,10 +44,13 @@
       Source: NEWS.md
     
+
+

ggmagnify (development version)

+
  • New corners argument sets corner radius on target and inset. Thanks to @thomasp85 for help with this.
  • +

ggmagnify 0.2.0

-
  • First CRAN release.
  • -
  • +
    • from and to can now be mapped to aesthetics, allowing different targets in different facets.
      • from can now be a logical vector of points to select.
      • @@ -62,7 +65,8 @@

        ggmagnify 0.2.0
      • Added some helper functions to find rectangles, convex hulls and grobs.
      • Added a NEWS.md file to track changes to the package.
-
+