Code Monkey home page Code Monkey logo

ggpp's Introduction

GitHub stats

Computing-related Skills

Programing: R, (Python), C++, (Java), C, bash, awk, Perl, sh, (FORTRAN), Modula-2, Pascal, BASIC, Forth.

Text mark up: $\LaTeX$, $\TeX$, Quarto, Rmarkdown, markdown, HTML.

Revision control systems: git, svn, (cvs), rss.

Drafting: Inkscape, OpenSCAD, Adobe Illustrator.

Image/photography: Capture One, Helicon Focus, Lumariver Profile Designer, RawDigger, VueScan, LightRoom, Photoshop.

Video- and interactive tutorials: FlashBack Pro, R shiny.

IDE/GUI’s I like

WinEdt (for $\LaTeX$, $\TeX$, with embedded R code or not), RStudio (for R scripts, Quarto and Rmarkdown), GitKraken (for git).

Elsewhere

ORCID profile: ORCID logo https://orcid.org/0000-0003-3385-972X

Web site for the book Learn R: As a Language.

R Packages

The sources of the R packages I have published are in public Git repositories at GitHub. Out of the packages that I have authored and maintain, 14 are currently available through CRAN. The total number of packages submissions (mostly updates) as author and maintainer is 203 since 2016-01-29.

I have published in CRAN one package update roughly every 15 days, or about 1.97 package updates per month, since 2016-01-29.

The most recent of these updates was published in CRAN on 2024-07-01.

📂 Click to expand a list of my packages at CRAN with the most recently updated one at the top.
R package Title Version Date
ggpp Grammar Extensions to ‘ggplot2’ 0.5.8-1 2024-07-01
ggpmisc Miscellaneous Extensions to ‘ggplot2’ 0.6.0 2024-06-28
gginnards Explore the Innards of ‘ggplot2’ Objects 0.2.0 2024-05-01
learnrbook Datasets and Code Examples from P. J. Aphalo’s “Learn R” Book 2.0.1 2024-04-28
photobiologyPlants Plant Photobiology Related Functions and Data 0.5.0 2024-04-02
photobiologySun Data for Sunlight Spectra 0.5.0 2024-04-01
photobiology Photobiological Calculations 0.11.2 2024-03-31
photobiologyFilters Spectral Transmittance and Spectral Reflectance Data 0.6.0 2024-02-27
photobiologyLEDs Spectral Data for Light-Emitting-Diodes 0.5.2 2023-11-01
photobiologyLamps Spectral Irradiance Data for Lamps 0.5.2 2023-10-24
photobiologySensors Response Data for Light Sensors 0.5.1 2023-10-24
photobiologyWavebands Waveband Definitions for UV, VIS, and IR Radiation 0.5.2 2023-10-24
ggspectra Extensions to ‘ggplot2’ for Radiation Spectra 0.3.12 2023-10-21
photobiologyInOut Read Spectral and Logged Data from Foreign Files 0.4.27 2023-07-20

Updates under development are published at R-Universe as soon as merged or commited into the main branch in the repositories at GitHub. Two packages that depend on a commercial closed-source driver, but usable with a free runtime of the driver, are published only at R-Universe.

R-Universe profile: https://aphalo.r-universe.dev. :name status badge :packages status badge

Posts and Pages at R for Photobiology

The site R for Photobiology contains 95 posts and pages published since 2016-09-15! I have recently rebuilt the site using Quarto, and I have transferred only some of the posts originally published using WordPress. I am slowly adding more old posts, but only those that remain relevant. The figure below shows original publication date even when posts have been later updated. The source files are in a public repository at GitHub.

I have published one post or page roughly every days, or about 1.0 posts per month, since 2016-09-15.

I published the most recent post 1 days ago.

📂 Click to expand a full list of posts.
Date Title
2024-07-13 “R Packages: Timeline of Updates”
2024-07-10 “Multichannel LED arrays”
2024-06-11 “Move from Wordpress to Quarto”
2024-06-01 “Fitted-model labels in Markdown”
2024-05-28 “Looking back 40 years”
2024-05-16 “Is this a polynomial?”
2024-04-17 “Annotating Plot Matrices”
2024-02-10 “Repository migrated to R-Universe”
2024-01-13 “ooacquire: Spectral Irradiance Algorithms”
2023-11-27 “Linear Models”
2023-11-21 “Theoretical probability distributions”
2023-11-18 “Flow of code execution”
2023-10-30 “Introduction to Data Visualization”
2023-10-21 “photobiology 0.11.x”
2023-10-21 “Design of Experiments”
2023-09-19 “R at its simplest”
2023-08-19 “Research as a process”
2023-08-19 “Research as a process”
2023-08-14 “Multiple comparisons with ggpmisc”
2023-08-01 “Pairwise labels with ggpp”
2023-07-31 “Open Access Weather and Climate Data”
2023-07-30 “Timelines with ggplot2”
2023-06-25 “Fitted-model labels with ggpmisc and plotly”
2023-06-24 “Fitted-model labels with ggpmisc and gganimate”
2023-06-10 “ooacquire 0.4.x”
2023-06-02 “Functional analysis of spectra with photobiology to fda.usc”
2023-05-30 “Model fitting in R”
2023-05-30 “Randomization and independent replicates”
2023-05-28 “photobiology 0.10.1x”
2023-05-24 “EDA with ggplot2”
2023-05-21 “I have started using Mastodon…”
2023-05-11 “Plant photoreceptors”
2023-05-03 “ggplot2 Basics”
2023-04-27 “Spectral fluorescence with ooacquire”
2023-04-27 “ooacquire: Spectral Irradiance Measurement”
2023-04-15 “Weather data for Finland from FMI”
2023-04-10 “ooacquire 0.3.x”
2023-03-20 “OmniDriver, Java and the whims of companies”
2023-03-04 “R Packages”
2023-02-28 “Packages ggpmisc, ggpp and gginnards”
2023-02-28 “Nudging + repulsion with ggrepel and ggpp”
2023-02-27 “Website migrated to Quarto”
2023-02-27 “Fitted-model labels with ggpmisc”
2023-02-25 “Volcano and quadrant plots with ggpmisc”
2023-02-25 “Data labels in bar plots with ggpp”
2023-02-23 “ggplot insets with package ggpp”
2023-02-20 “Handbook on photobiological calculations with R”
2023-02-20 “A handbook of best practice in plant UV photobiology”
2023-02-19 “The R for Photobiology Suite”
2023-02-19 “Pedro J. Aphalo”
2023-02-18 “R, RStudio and Quarto”
2023-02-18 “Support”
2023-02-15 “About this Website”
2023-02-03 “ggspectra 0.3.10/0.3.11/0.3.12”
2023-01-05 “photobiologyWavebands 0.5.1”
2023-01-05 “photobiology 0.10.15”
2022-12-30 “Are plants and plant canopies flat?”
2022-12-23 “Visit to Universidad Austral de Chile”
2022-12-17 “Enhancing geom_text() and geom_label()”
2022-12-05 “ggpp >= 0.5.0 updates”
2022-10-18 “ooacquire 0.2.6”
2022-10-15 “An R marathon updating packages”
2022-10-15 “photobiologyInOut 0.4.25/0.4.26/0.4.27”
2022-10-15 “photobiology 0.10.14”
2022-10-15 “ggspectra 0.3.9”
2022-10-15 “gginnards >= 0.1.1 updates”
2022-10-05 “photobiology 0.10.13”
2022-10-01 “ooacquire 0.2.4 and 0.2.5”
2022-09-30 “ggpp 0.4.5”
2022-08-24 “Learn R: As a Language”
2022-08-13 “HTML5 compliance of R packages”
2022-08-13 “photobiologyWavebands 0.5.0”
2022-08-05 “ggpmisc >= 0.5.0 updates”
2022-07-23 “photobiology 0.10.12”
2022-07-10 “photobiology 0.10.11”
2022-06-15 “ggpmisc 0.4.7”
2022-05-15 “photobiologyInOut 0.4.24”
2022-05-14 “photobiologyLEDs 0.5.0”
2022-04-29 “R 4.2.0”
2022-04-16 “ggspectra 0.3.8”
2022-01-30 “Instrumentation”
2022-01-30 “Controlled Environment Chambers”
2022-01-29 “LED-based light sources”
2021-10-20 “What is plant intelligence? and what it is not?”
2021-10-17 “Sensing of solar UVA by plants”
2021-10-17 “Cryptochromes and stomatal opening”
2021-07-13 “Perception of solar UV radiation by plants”
2020-07-12 “Performance of package photobiology”
2020-04-25 “UVR8 is an UV-B and UV-A photoreceptor”
2019-04-24 “Benchmarking function sun_angles()
2019-02-22 “Yoctopuce modules: Spectrometer”
2019-02-21 “Yoctopuce modules: Introduction”
2018-08-10 “Using the Quick TUV Calculator”
2017-11-24 “Article titles in the era of the internet”
2016-09-15 “For those interested in optical properties”

Posts and pages at Photo Rumblings and Whispers

The Photo Rumblings and Whispers has 27 posts since 2015-10-18! I have recently rebuilt the site using Quarto, and I have transferred most of the posts originally published using WordPress. I may add one or two old posts. The figure below shows original publication date even when posts and pages have been later updated. I have updated several of the posts and pages and I aim to continue updating them as needed. The source files are in a public repository at GitHub.

I have published one post or page roughly every days, or about 0.3 posts per month, since 2015-10-18.

I published the most recent post or page 154 days ago.

📂 Click to expand a full list of posts.
Date Title
2024-02-11 “The nitty-gritty details of macrophotography”
2023-08-28 “Photographing Insects: Lenses”
2023-08-22 “WordPress -> Quarto”
2023-08-21 “Pedro J. Aphalo”
2023-05-13 “Flexible and oversized lens hoods”
2023-04-18 “About this Website”
2023-04-15 “UV short-pass filter stacks”
2023-04-14 “UV short-pass filters”
2023-04-12 “Notes on the OM-1 (digital) camera”
2022-10-15 “Small fill/video LED lights revisited”
2021-10-25 “Broad band VIS+NIR LEDs”
2021-08-21 “Photo Rumblings and Whispers”
2021-02-01 “NIR long-pass filters”
2020-09-29 “Hemispherical time-lapse under a tree”
2020-06-30 “Lens Adapter with Filter Drawer”
2020-06-30 “Lens Adapters: Flange-to-Flange Distance”
2020-06-12 “UV-cut filters”
2020-06-11 “UV-IR-cut filters”
2019-08-21 “A time lapse video assembled in ImageJ”
2019-07-14 “Godox AD200 flash for UV, VIS and IR photography”
2019-07-14 “Digital UVA-photography with M43 equipment”
2019-06-19 “Lautaret”
2019-05-11 “Neutral Density (ND) Filters”
2018-05-13 “Camera objectives for digital UV photography”
2017-12-12 “Black anodised aluminium in IR”
2017-10-28 “Photographs through windows”
2015-10-18 “Bracketing”

Updated 2024-07-14 10:33:58.507133

This README file is based on the blog post by Athanasia Mo Mowinckel and the R code by Martin Henze.

ggpp's People

Contributors

alexjoerich avatar aphalo avatar cicdguy avatar danielinteractive avatar sob2021 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ggpp's Issues

Check compatibility with 'ggbreak'

Time back the NPC geoms did not work together with 'ggbreak'. Check current situation and see if problems continue. If yes, see if this can be fixed.

`"spread"` action in `position_nudge_to()`

How this position function would work is to nudge positions so that they are evenly spread (at the same distance from each other) within a range given by the first and last positions. This should be very easy to implement, specially in comparison to implementing position_repulse(), so I have separated position_spread() here from from position_repulse() described in issue #6 where it was originally mentioned.

geom_zebra_bands()

A geom to highlight boundaries, such as day and night or times with abnormal data, etc. It would be similar to geom_col() but not anchored on zero. It would use aesthetics ymin and ymax, with -Inf and Inf supported for edge to edge bands. geom_col() does not support -Inf mapped to y, and is based at zero. geom_area() seems to fail with POSIXct mapped to x. Ideally alpha should affect both fill and colour.

The example below was produced with two geom_col() layers.

  geom_col(aes(x = time,
               y = Inf,
               fill = day_or_night),
           alpha = 0.1) +
  geom_col(aes(x = time,
               y = -5,
               fill = day_or_night),
           alpha = 0.1) +
  scale_fill_manual(name = "",
                    values = c(day = "yellow", night = "grey50"),
                    aesthetics = c("colour", "fill")) +

Rplot

Clean documentation

After updating the code, the details section of geom_table() and geom_plot() documentation needs to be updated.

Examples all work, but there are couple of duplicated ones that need to be made different.

The new functionality needs to be described, at least briefly in the vignette.

Upgrade minimal lubridate version

Hi!

First of all, thank you for all your work in improving the package itself as well as its testing suite! It looks awesome!

I have a minor suggestion to the DESCRIPTION of the package, in particular minimal version of lubridate

lubridate (>= 1.7.9),

While testing the package in a slightly older, regulatory environment I discovered that running lubridate lower than 1.9.0 makes ggplot.ts fail. I thought you might want to know this as these failures indicate that there might be something wrong with the function itself, as it compares raw data against the plot values.

── Failure (test-ggplot_ts.R:35:3): ggplot.ts time resolution works as expected. ──
res$x not equal to `expected_pos`.
1764/3177 mismatches (average diff: 31556865)
[1]  -6.97e+09 - -6.94e+09 == -31536000
[2]  -6.97e+09 - -6.94e+09 == -31536000
[3]  -6.97e+09 - -6.94e+09 == -31536000
[4]  -6.97e+09 - -6.94e+09 == -31536000
[5]  -6.97e+09 - -6.94e+09 == -31536000
[6]  -6.97e+09 - -6.94e+09 == -31536000
[7]  -6.97e+09 - -6.94e+09 == -31536000
[13] -6.94e+09 - -6.91e+09 == -31536000
[14] -6.94e+09 - -6.91e+09 == -31536000
...

── Failure (test-ggplot_ts.R:63:3): ggplot.ts mapping works as expected. ───────
res$xmiddle not equal to `expected_med`.
27/27 mismatches (average diff: 11.6)
[1] 46.15 - 75.7 == -29.55
[2] 44.65 - 37.7 ==   7.00
[3] 48.65 - 51.6 ==  -2.95
[4] 40.50 - 59.9 == -19.40
[5] 71.85 - 67.7 ==   4.20
[6] 21.20 - 28.4 ==  -7.25
[7]  8.05 - 29.6 == -21.50
[8] 20.55 - 19.2 ==   1.30
[9] 41.80 - 19.3 ==  22.50
...

── Failure (test-ggplot_ts.R:64:3): ggplot.ts mapping works as expected. ───────
res$xlower not equal to `expected_q1`.
26/27 mismatches (average diff: 10.1)
[1] 27.000 - 65.38 == -38.38
[2] 26.150 - 14.25 ==  11.90
[3] 26.950 - 29.78 ==  -2.83
[4] 15.775 - 28.22 == -12.45
[5] 47.675 - 27.82 ==  19.85
[6]  7.200 -  8.40 ==  -1.20
[7]  0.475 - 11.25 == -10.78
[8]  3.475 -  2.38 ==   1.10
[9] 15.575 -  3.55 ==  12.02
...

── Failure (test-ggplot_ts.R:65:3): ggplot.ts mapping works as expected. ───────
res$xupper not equal to `expected_q3`.
24/27 mismatches (average diff: 11.4)
[1]   71.6 -  85.0 == -13.475
[2]   61.3 -  51.1 ==  10.250
[3]   78.0 -  73.0 ==   5.000
[4]  104.8 - 110.2 ==  -5.475
[5]  112.8 - 112.4 ==   0.375
[6]   39.8 -  59.2 == -19.425
[7]   18.7 -  42.8 == -24.100
[9]   56.2 -  49.4 ==   6.700
[10] 100.2 - 101.2 ==  -1.025
...

[ FAIL 4 | WARN 0 | SKIP 0 | PASS 10 ]

Increasing lubridate to at least 1.9.0 solves the issue. Hence my suggestion is to put is as a minimal version so users installing the package in older environments would be forced to upgrade lubridate rather than using potentially malfunctioning functions.

In stat_dens_... functions support quadrants

I think, specially for genomics, it could be useful to be able to set the arguments to keep.fraction and keep.number parameters separately for each plot quadrant. This is doable, but will need to wait until I have more free time, as it will most likely take a whole day to implement and test. See also #19. The UI could be implemented by accepting vectors of length 4 for in addition to verctors of length 1 by these two parameters

Special position function to stack error bars

A position function to add error bars to stacked columns could be implemented by applying the same displacement to ymin and ymax as to y.

Should be fairly easy to implement. position_stack() from 'ggplot2' messes up the error bars.

Increasing test coverage?

Hi @aphalo , first of all thanks for the nice package, really useful extensions here!

One question - we are currently looking into this package (actually only a few of its functions) to use for cases where we need to "validate" the packages. Without going into details, the hard requirement there is to have sufficient unit test coverage of the package.
So currently we see around 20% test coverage in ggpp. But we would need at least 80% overall, and each function tested at least with one test, to get through our requirements.

I was wondering - would you be open to us contributing tests via PRs? Since that seems the most straightforward way.

Cheers
Daniel

Enhance action `"spread"` in `position_nudge_to()`

This is a note about something to consider in the future. In 'ggrepel' repulsion is applied during rendering, so it tracks changes in plot size. This is advantageous in some respects, but means that repulsion will result in different plot layouts depending on the graphical device and width and height parameters passed to it. A different compromise solution is to apply the repulsion with a position function.

While position_repulse() would depend on a random shift component, position_spread() would work deterministically.

Labels not drawn if density calculation fails due to few points

I've run into an issue where stat_dens2d_filter does not draw labels although they satisfy the requirements specified by keep.fraction and keep.number.

A simple example would be the following:

ggplot(data.frame(x=1,y=1,label="label"), aes(x=x,y=y)) +
    geom_point() +
    ggpp::stat_dens2d_filter(aes(label=label), geom="text", keep.number=Inf, keep.fraction=1)
# Warning messages:
# Computation failed in `stat_dens2d_filter()`
# Caused by error in `if (any(h <= 0)) ...`:
# ! missing value where TRUE/FALSE needed

image

Maybe it's worth skipping the density calculation if there are fewer points in the data set than should pass the filter?

Future ggplot2 3.5.0 breaks geom_label_s() and geom_label()

In addition to the expected small change in boxes in those geoms that call ggplot2::GeomLabel these to geoms that generate their own grobTrees silently display only the segments. I suspect an internal change in 'ggplot2' affecting the construction or addition of the grobs to the plot. However, I need to check what is going on.

`position_waterfall()` from 'ggbg'

Consider adding an updated version of position_waterfall() from package 'ggbg' to 'ggpp'. 'ggbg' is not in CRAN, but I could ask the author about adding it to 'ggpp' as a contribution. It is released under GPL (>=2) as 'ggpp' also is. The update would be mainly to add the keeping of previous positions using the naming conventions of 'ggpp' for consistency.

brodieG /
ggbg

Nudging `x` when `y` is a grouping factor using `position_stacknudge()`

I want to offset the bar graph so that the fill boundary is zero using position_stacknudge and position_fillnudge as shown below.

library(tidyverse)

D <-
  tibble(
    team = c("A", "A", "A", "B", "B", "B", "C", "C", "D", "D", "D"),
    value = c(0.1, 0.2, 0.7, 0.3, 0.2, 0.5, 0.4, 0.6, 0.6, 0.3, 0.1),
    category = c("i", "j", "k", "i", "j", "k", "i", "k", "i", "j", "k")
  )

# Calculate the amount of offset from the data frame.
# For each bar, we want to shift the "category" to the left by the "i" "value,"
# so we create an "h_move" column and for each "TEAM" give each row the "i" "value" of that "TEAM".
# 
# Sort this using "team" and "h_move" as keys, and take it out as a vector.
h_move <-
  D %>% 
  group_by(team) %>% 
  mutate(
    h_move = -sum(if_else(category == "i", value, 0))
  ) %>% 
  arrange(team, h_move) %>% 
  pull(h_move)

D %>% 
  ggplot(mapping = aes(x = value, y = team, fill = category)) +
  geom_col(
    color = "black",
    position = ggpp::position_stacknudge(reverse = TRUE, x = h_move)
  )

Rplot

Next, to rearrange the order of the bars, convert the "team" column to factor and set the order with the "levels" option.

Running the same code as above with this data, the order of the vectors (h_move), which determines the amount of offset, and the bars that are actually offset are shifted. As a result, the boundary between "i" and "j" in "category" is not zero as shown below.

library(tidyverse)

D <-
  tibble(
    team = c("A", "A", "A", "B", "B", "B", "C", "C", "D", "D", "D"),
    value = c(0.1, 0.2, 0.7, 0.3, 0.2, 0.5, 0.4, 0.6, 0.6, 0.3, 0.1),
    category = c("i", "j", "k", "i", "j", "k", "i", "k", "i", "j", "k")
  ) %>% 
  mutate(
    team = factor(team, levels = c("B", "D", "A", "C"))
  )

h_move <-
  D %>% 
  group_by(team) %>% 
  mutate(
    h_move = -sum(if_else(category == "i", value, 0))
  ) %>% 
  # The order of the "TEAM" column depends on the LEVELS of the FACTOR.
  arrange(team, h_move) %>% 
  pull(h_move)

D %>% 
  ggplot(mapping = aes(x = value, y = team, fill = category)) +
  geom_col(
    color = "black",
    position = ggpp::position_stacknudge(reverse = TRUE, x = h_move)
  )

Rplot01

When giving the vector to the "x" option, shouldn't it also take into account FACTOR in the order in which the amount of movement is applied? Currently it seems to depend on the order of the rows of the data frame given to ggplot. For example, if you randomize the data before passing it to ggplot as shown below, you will get a funny result.

library(tidyverse)

D <-
  tibble(
    team = c("A", "A", "A", "B", "B", "B", "C", "C", "D", "D", "D"),
    value = c(0.1, 0.2, 0.7, 0.3, 0.2, 0.5, 0.4, 0.6, 0.6, 0.3, 0.1),
    category = c("i", "j", "k", "i", "j", "k", "i", "k", "i", "j", "k")
  )

h_move <-
  D %>% 
  group_by(team) %>% 
  mutate(
    h_move = -sum(if_else(category == "i", value, 0))
  ) %>% 
  arrange(team, h_move) %>% 
  pull(h_move)

D %>% 
  # randomize the order of rows
  slice_sample(prop = 1) %>% 
  ggplot(mapping = aes(x = value, y = team, fill = category)) +
  geom_col(
    color = "black",
    position = ggpp::position_stacknudge(reverse = TRUE, x = h_move)
  )

Rplot02

This package is very good for creating offset bars as shown above. It would be even better if it were easy to create offset bars without having to create a vector to determine the amount of offset.

thank you.

`geom_text_s()` and `geom_label_s()` guide not visible when there is a mapping to size

  • Check 'ggplot2' issues for a known problem
  • Read documentation on 'ggplot2' guides
  • Try to fix or look for advice

Reprex below run with 'ggplot2' 3.5.0 installed from GitHub on 29 February

library(ggpmisc)
#> Loading required package: ggpp
#> Loading required package: ggplot2
#> Registered S3 methods overwritten by 'ggpp':
#>   method                  from   
#>   heightDetails.titleGrob ggplot2
#>   widthDetails.titleGrob  ggplot2
#> 
#> Attaching package: 'ggpp'
#> The following object is masked from 'package:ggplot2':
#> 
#>     annotate
#> Registered S3 method overwritten by 'ggpmisc':
#>   method                  from   
#>   as.character.polynomial polynom

### BUG in geom_text_s and geom_label_x

my.cars <- datasets::mtcars[c(TRUE, FALSE, FALSE, FALSE), ]
my.cars$name <- rownames(my.cars)

ggplot(my.cars, aes(wt, mpg, label = name)) +
  geom_point() +
  geom_text(aes(size = wt), nudge_x = -0.1, hjust = "right") +
  scale_radius(range = c(3,6)) + # override scale_area()
  expand_limits(x = c(1.8, 5.5))

### text missing from guide

ggplot(my.cars, aes(wt, mpg, label = name)) +
  geom_point() +
  geom_text_s(aes(size = wt), nudge_x = -0.1, hjust = "right") +
  scale_radius(range = c(3,6)) + # override scale_area()
  expand_limits(x = c(1.8, 5.5))

ggplot(my.cars, aes(wt, mpg, label = name)) +
  geom_point() +
  geom_text_s(aes(size = wt), nudge_x = -0.1, hjust = "right") +
#  scale_radius(range = c(3,6)) + # override scale_area()
  expand_limits(x = c(1.8, 5.5))

###

ggplot(my.cars, aes(wt, mpg, label = name)) +
  geom_point() +
  geom_label_s(aes(size = wt), nudge_x = -0.1, hjust = "right") +
  scale_radius(range = c(3,6)) + # override scale_area()
  expand_limits(x = c(1.8, 5.5))

###

ggplot(my.cars, aes(wt, mpg, label = name)) +
  geom_point(color = "red") +
  geom_point_s(aes(size = wt), nudge_x = -0.5) +
  scale_radius(range = c(1,2)) + # override scale_area()
  expand_limits(x = c(1.8, 5.5))

Created on 2024-03-02 with reprex v2.1.0

Submit updated 'ggpmisc' 0.4.5

The renaming of geom_text_linked() makes it necessary to update two code examples in 'ggpmisc' and get the new version to CRAN before reverse dependency checks for the 'ggpp' 0.4.3' can be passed. Alternatively maintain the old name as deprecated until '0.4.4' is released. As there is an additional problem in 'ggpmisc' submitting this minor update straight away seems a better option.

Support fraction and percent of observations in `stat_quadrant_counts()` and `stat_group_counts()`.

ref: Robin's question

Instead of only supporting counts, support in addition fraction of observations and percent of observations.

To implement this in stat_group_counts() I need to replace the current use of a compute group function by a compute panel function adapted from that in stat_quadrant_counts() because to compute fractions of total we need access to all data when generating the labels for separate groups. At the same time one could possibly automate the support for factors mapped to x or y.

Tag CRAN release versions?

It would be great if the CRAN release versions were also tagged (and maybe mirrored by a github "release") in this repository, so a user can compare which code changed between versions.

The code for this would be simply:

git tag -a "vX.Y" # with release notes
git tag "vX.Y" # without

on the same commit as is pushed to CRAN.

For an example, see here (annotated tags and releases) or in ggrepel (tags only).

Justification and the new nudge functions

This issue belongs here in 'ggpp' although it is in 'ggpmisc' as it was openned before the package split: aphalo/ggpmisc#3

It needs to be explored if justification could be also adjusted for each text label dynamically in the position functions in the same way as the nudges are. This would be very useful when the length of the label text varies, as in this case constant nudge would result in varying distances.

Test geoms with maps and projections and add examples

Brief description of the problem

Support for sf data for maps has been added to 'ggplot2' some time ago, but 'ggpp' has not been tested for labelling of maps.

Example user interface and/or plot output.

Add examples to documentation, and unit tests to testthat folder.

Bug in handling `nudge` that is a "long" vector

The most logical approach with the nudge argument would be to accept numeric vectors of any length and recycle them. One case works after today's edits correctly with three position functions: position_nudge_keep(), position_nudge_to() and position_nudge_center(). This case is when x or y are longer than 1, but shorter than the number of rows in data. In this case not only recycling needs to be done but also reordering so as to support the frequent use case of nudging labels alternatively in opposite directions or by different distances. This is an effective approach to reduce overcrowding.

Another case that needs to be handled with a warning is when the x or y vectors are longer that rows are present in data. This needs to be implemented in all the nudging position functions.

This needs to be also implemented in the remaining position functions that support nudging.

How to deal with the 'ggplot2' 3.5.0 update?

NPC translation functions to support named positions

With 'ggplot2' 3.5.0, support is built-in, but with a different syntax, making the _npc geoms from 'ggpp' rather redundant. The changes in 'ggplot2', however, do not break the current _npc geoms. On the other hand, getting rid of the pseudo aesthetics npcx and npcy would simplify maintenance.

I have become used to setting positions based on words and allowing this would easy the transition from the 'ggpp' syntax to the new syntax supported natively by 'ggplot2'.

There are several possible approaches:

  1. as.npc() could be used as x = as.npc("left") this could use other names, or in fact could use the existing functions for justification This could be a pull resquest to 'ggplot2'.
  2. aes_npc()
  3. npcx() and npcy()
  4. Rewrite the existing _npc geoms as wrappers using the new syntax.

Border or enclosing box for insets

It could be useful to make it possible to add a box to insets (plots, tables and grobs). Interface should use the same parameter names as geom_label_s().

Add example?

The 'ggplot2' 3.4.0 update added stat_align() which seems very useful (e.g. for spectra). An example of its use for staked areas could be added.

Use 'grid' to clip segments in `geom_text_s()`, `geom_label_s()`, `geom_label_pairwise()` and `geom_text_pairwise()`.

In geom_label_pairwise() the segment behind the label box becomes visible when the box fill is transparent. This is a bug.
In geom_text_pairwise() the default position of the text causes no problem, but if centred on the segment the text is crossed out!
In geom_text_s() and geom_label_s() clipping to the "padded text or box" would greatly simplify the code used for drawing segments as they could be drawn from the center of the text or label grobs.

Support `angle` aesthetic in `geom_label_s()`

This feature has been asked for repeatedly for 'ggplot2'. It seems that R 4.2.0 by introducing in 'grid' the possiblity of creating grouped grobs should make implementing angle straightforward. It is, I think still too early to add a feature that requires an R version that is less than a year old. So, this is a note for the future.

Error for duplicate aesthetic `colour.target` with `color.target` passed to ...

colour.target is a formal parameter, not an aesthtic. However, if the user uses name color.target by mistake, it gets converted in the bowels of 'ggplot2' into colour.target and it clashes with the existing parameter colour.target.
color.target needs to be detected and removed from ... before assembling the layer params.

stat_functions()

stat_function() from 'ggplot2' works like an annotation, and accepts a single function. This does not match the expectations of the grammar of graphics. In the new stat_functions() the functions would be in a list column in data, the code in the stat would compute y values for each function from x values if available in data. Unlike stat_function(), x values would not be generated automatically, but possibly sparse vectors giving a range could be populated by interpolation (opposite to stat_summary() the returned data object would have more rows than the input data object).

If 'ggplot2' code can do the aesthetic mapping as it does for whole data frames and gg objects for insets, this would be fairly easy to implement.

An alternative would be to prepare a pull request to 'ggplot2' revising stat_function() to accept vectors or lists as geom_hline() and similar functions do.

The idea was triggered by the necessarily complex and inelegant code included in a question at StackOverflow as example, not by the question itself.

geom_table_npc() with ggplot() + facet_grid() not working

Hi @aphalo ,

I am trying to put a separate table per facet of a ggplot but can't get it working
I've tried following these links so far
https://docs.r4photobiology.info/ggpp/reference/geom_table.html#ref-examples
https://stackoverflow.com/questions/64811173/is-it-possible-to-use-geom-table-along-facet-grid
https://stackoverflow.com/questions/25554548/adding-sub-tables-on-each-panel-of-a-facet-ggplot-in-r?

1 - Extract required data from huge DF

mydata <-
  RIII_ALLDATA_DonorAveraged_long %>%
  dplyr::filter(!Compound1Concentration > 100) %>% 
  dplyr::filter(!marker %in% c("CD25", "CD137", "CD19", "CD107a")) %>% 
  dplyr::filter(statType == "Count") %>% 
  dplyr::filter(CellPop %in% c("AllCD3+ AllCD4+",
                               "AllCD3+ AllCD8+",
                               "AllCD3+ CD4+CD8+"))
  dplyr::filter(Labels %in% c("no drug control",
                              "Treatment 1",
                              "Treatment 2",
                              "Treatment 3",
                              "Treatment 4")) %>%
  dplyr::mutate(Labels = fct_recode(Labels,
                                    NDC = "no drug control"))

2 - Set up the plot

gg <- 
  ggplot(mydata,
         aes(x = Compound1Concentration,
             y = value,
             fill = CellPop)) + 
  geom_bar(position = "stack", stat = "identity", color = "black") +
  facet_grid(CellLine ~ Labels, scales = "free_x", space = "free") + 
  scale_fill_nejm() + 
  x.axis.DRClow + 
  # scale_y_continuous(labels = scales::percent_format(accuracy = 1)) +
  labs(x = "Treatment (pM)") 

3 - now try to put a table of values below each facet of the plot

tb <- mydata

# split big df of all data into list of separate dfs by cell line
tbs <- split(tb, tb$CellLine)

# make a new nested dataframe including faceting variable, x and y coordinates for table, and list of tables
dfnpc <- tibble(x = rep(0.5, length(tbs)),
                y = rep(0.5, length(tbs)),
                CellLine = levels(tb$CellLine),
                tbl = tbs)


gg + geom_table_npc(data = dfnpc,
                    aes(npcx = x,
                        npcy = y,
                        label = tbl))

The plot works independently of the geom table bit. When I try the gg + geom_table_npc(...) R just hangs
Please help!

'grid' graphics updates: documentation for #7, #35 and #49.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.