Questions tagged [ggpmisc]

The ggpmisc tag should be used for questions related to the use of R package 'ggpmisc'.

The ggpmisc tag should be used for questions related to the use of R package 'ggpmisc'. Bug reports and requests for enhancements should not be posted here, but instead informed to the maintainer by raising an issue at https://bitbucket.org/aphalo/ggpmisc/issues.

The 'ggpmisc' R package is available through CRAN, and includes detailed documentation. This same documentation is also available in HTML format at http://docs.r4photobiology.info/ggpmisc and can be looked at without need to install the package. The source code of the package is in a public Git repository at https://bitbucket.org/aphalo/ggpmisc.

Functions are provided to convert time series objects into data frames or tibbles suitable for plotting with R package 'ggplot2'. To complement these functions ggplot() methods for "ts" and "xts" classes are also defined.

Different statistics, geometries and functions add facilities for labelling peaks and valleys, generating labels for fitted models including polynomial equations, highlighting deviations from a model fit, and for filtering-out regions of plot panels with high densities of observations (with stats designed to work nicely together with R package 'ggrepel').

Geometries for adding layers with inset tables, ggplots or 'grid' grobs are also defined together with versions of geom_text and geom_label that use 'grid' npc coordinates instead of data coordinates supported by new aesthetics npcxand npcy and corresponding scales.

81 questions
3
votes
3 answers

Editing *row* names of tabular display when using stat_fit_tb() in ggpmisc & ggplot

While stat_poly_eq() allows variable names to be changed using eq.with.lhs and eq.x.rhs, a similar functionality does not seem to be available within stat_fit_tb(), according to my reading of the ggpmisc documentation. Is there a way of modifying…
Big Old Dave
  • 343
  • 2
  • 11
3
votes
1 answer

Change table theme when using ggpmisc::geom_table_npc

This question uses 'ggpmisc' version 0.3.4 or earlier, see answer below for version 0.3.5 or later. I like the newish geom_table_npc in ggpmisc which provides a simple way to add a table to a ggplot and works particularly well with transformed…
Sarah
  • 3,022
  • 1
  • 19
  • 40
3
votes
1 answer

Labeling extrema with stat_peaks/stat_valleys produces duplicate labels

I extracted some longitudinal temperature data from a .nc weather dataset (ncdf4 package) and would like to label the local extrema with their respective dates from x-axis using ggplot2 and its extension ggpmisc that includes…
2
votes
0 answers

Manual position of stat_poly_eq labels with facet_wrap being another variable than e.g. color does not work

I have a dataframe (df) which looks something like this: #Creating sample data RE <- c(0.95, 0.8, 0.7, 0.85, 0.5, 0.3, 1, 0.8, 0.2, 0.95, 0.4, 0) TimeSinceStart <- c(10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30) Name <- c("A","A","A","B","B","B",…
2
votes
3 answers

Modifying the decimal mark of stat_poly_eq

I use the stat_poly_eq function from the ggpmisc package to add the regression equation in my ggplots. It works perfectly. However, I'd like to change the decimal mark of the equation from period to comma, and I can't figure out how to do this. Any…
2
votes
1 answer

How to fill the background of a stat_poly_eq equation (ggpmisc) using ggplot2?

Is there a way to fill the background of a stat_poly_eq equation ggpmisc with white color (or any other color) so that the black lines of the panel.grid are hidden? # Data df <- data.frame(x = c(1:100)) df$y <- 2 + 3 * df$x + rnorm(100, sd =…
denis
  • 199
  • 1
  • 8
2
votes
1 answer

R scientific notation in stat_poly_eq

I am currently using the code for stat_poly_eq in ggplot2 and was wondering if there is a way to always get the values on the graph in xe+1? So far it only gives me the Xx10^1 when the value is very high or very low. I would like it to always be in…
ZuZu
  • 23
  • 5
2
votes
2 answers

Can't get R2 values in two decimal using ggplot2 and ggpmisc

I am sorry that I don't know how to make reproducible example while asking for help here. Therefore, I am providing the code below and data; <350 KB here (data: https://easyupload.io/1r5xuo), if you can look at. My problem is: I want to have two…
2
votes
1 answer

Color ggscatter by R and P values

I'm plotting a wrapped ggscatter like the image below. What I want is to color differently according to the R and P values. For example, when P is not significant, I want the plot gray; when P is significant is want the plot colored according the R…
2
votes
2 answers

How to force trailing zeroes in 'polynom::polynomial' object? (specifically to modify behavior of stat_lm and stat_regline_equation from ggpubr)

I am trying to modify how stat_regline_equation displays the regression line equation on a plot made with ggscatter from the R package ggpubr. Specifically, I want to show a consistent number of digits of coefficients, even when some rounded…
Carl
  • 83
  • 1
  • 7
2
votes
3 answers

Is there a neat approach to label a ggplot plot with the equation and other statistics from geom_quantile()?

I'd like to include the relevant statistics from a geom_quantile() fitted line in a similar way to how I would for a geom_smooth(method="lm") fitted linear regression (where I've previously used ggpmisc which is awesome). For example, this code: #…
Mark Neal
  • 996
  • 16
  • 52
2
votes
3 answers

Label ggplot with group names and their equation, possibly with ggpmisc?

I would like to label my plot, possibly using the equation method from ggpmisc to give an informative label that links to the colour and equation (then I can remove the legend altogether). For example, in the plot below, I would ideally have the…
Mark Neal
  • 996
  • 16
  • 52
2
votes
0 answers

How do I facet plots that each contain an inset plot?

I'm trying to plot time series data for each "Type" in a dataset, and I want to include an inset of a zoomed in portion of the data for each plot. I can get the inset to work on each individual plot, but the issue comes when I try to use faceting to…
GeochemKat
  • 21
  • 1
2
votes
2 answers

ggplot2: Problem with x axis when adding regression line equation on each facet

Based on the example here Adding Regression Line Equation and R2 on graph, I am struggling to include the regression line equation for my model in each facet. However, I don't figure why is changing the limits of my x…
Andrei Niță
  • 517
  • 1
  • 3
  • 14
2
votes
1 answer

What is the best way to calculate and display peaks of a ggplot2::geom_density() object?

I'm trying to find an easy and intuitive way to calculate and display the peaks of a ggplot2::geom_density() object. This blog explains how to do it in base R, but it is a multistep process. But it seems much more intuitive to use the stat_peaks()…
axme100
  • 377
  • 5
  • 13