Giter VIP home page Giter VIP logo

deeptime's People

Contributors

aegit avatar guangchuangyu avatar kguidonimartins avatar willgearty 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

Watchers

 avatar  avatar  avatar  avatar

deeptime's Issues

Use coord_geo with a graph used coord_flip

Is there a way to add a geological timescale to a graph with coords flipped? I am drawing an area plot so the x and y can not be exchanged in setting, but I hope the age could be put in a vertical way so the coords need to be flipped. Thanks.

Allow for custom data for discrete scales

There should be some way to have a discrete scale where the time bins are not 1:1 with the discrete axis bins (e.g., if you want both periods and stages on the axis). One solution for this would be to add an option/argument for coord_geo() that prevents the discrete conversion of the data (92d9ad2). This way, a user could provide their own data that is already set up for a discrete scale. Obviously, this argument would need to be able to be a list like other arguments, in case the user wants one scale to be converted to discrete and another not converted.

Updated ISC ages

Hello Will,

I was wondering if there is any way to update the package with the latest boundaries between periods and epochs with the last version of the international stratigraphic chart by the International Commission on Stratigraphy. For some time periods there is a great discrepancy between age boundaries used by the package (from 2013) and current ones.

Thanks in advance!

Better string handling in getScaleData()

The following enhancements should be made to getScaleData():

  1. Allow partial matching (e.g., "stage" should match to "stages")
  2. Better error handling if name does not match any timescale

I've found 2 errors installing deeptime

Hi, I've found these errors:

install_github("willgearty/deeptime")
ERROR: installing package DESCRIPTION failed for package 'ggnewscale'

  • removing 'C:/Users/XXX/Documents/R/win-library/3.6/ggnewscale'

ERROR: dependency 'ggnewscale' is not available for package 'deeptime'

  • removing 'C:/Users/XXX/Documents/R/win-library/3.6/deeptime'

Center time-interval names to the plotted part of the time interval

I noticed that there is much space in some scales that is not used efficiently. For example, in the "Stack multiple scales (e.g. periods, epochs, stages)" example on the readme file the word "Cretaceous" is positioned at the center of the Cretaceous. Thus, the word is cut off in the plot. Could the text element not be centered to the visible part of the time interval?

keep the output still a gg object

I think your old implementation is better for the output is still a gg object. And I can help to implement a scale_geo or geom_geoscale or geom_geo that can be added via the + operator, e.g. ggplot() + geom_geo().

What do you think?

Support for geological fill patterns

Got a new one for you @willgearty!...

We often use some kind of pattern fill for geological maps and sedimentary logs to indicate lithology. I wonder if making such an option available in deeptime could be useful for the community. Perhaps using something like the USGS swatches pack? I also found this package ggpattern which might provide a good starting place for how this could be implemented?

grid in background

Hi Will,
I use your gggeo_scale_old() function a lot to build time tables of fossil occurrences - and I absolutely love it! I have a suggestion, which I think could be helpful for other users as well: To better see whether a data point is part of a certain age interval a 'grid' in the background could be helpful. This would just be vertical or horizontal lines that needed to be plotted behind everything else and the option could be put be put as an argument of the gggeo_scale_old() function (or the up to date one). I would now do this in Inkscape afterwards or manually put lines in ggplot. I attached an image of how it could look like.
Best wishes,
Mario

timetable_censored

Need to load scales to use transformations in coord_geo

If you want to include a transformation within coord_geo, you need to load the scales package beforehand. If you don't load it beforehand, something like this won't work:

library(divDyn)
library(tidyverse)
data(corals)
coral_div <- corals %>% filter(stage != "") %>%
  group_by(stage) %>%
  summarise(n = n()) %>%
  mutate(stage_age = (stages$max_age[match(stage, stages$name)] + stages$min_age[match(stage, stages$name)])/2)
ggplot(coral_div) +
  geom_point(aes(x = stage_age, y = n)) +
  scale_x_reverse("Age (Ma)") +
  coord_geo(xlim = c(250, 0), ylim = c(1, 1700), ytrans = "log10") +
  theme_classic()

Should we include scales as a dependency so that it gets loaded when deeptime is loaded?

Issues with next version of ggplot2

Hi

We preparing the next release of ggplot2 and our reverse dependency checks show that your package is failing with the new version. Looking into it we see that your package somehow includes references to ggplot2 code from when it was build, which causes the check to emit the "Import not declared from..." error. Please see https://www.tidyverse.org/blog/2022/09/playing-on-the-same-team-as-your-dependecy/ for some more info about why this can cause issues.

You can install the release candidate of ggplot2 using devtools::install_github('tidyverse/[email protected]') to test this out.

We plan to submit ggplot2 by the end of October and hope you can have a fix ready before then

Kind regards
Thomas

Make gggeo_scale() work with multi-column facetted plots

gggeo_scale_old works for multi-column facetted plots because it's just putting the scale on the plot as a ggplot addition. However, ggeo_scale is using gtable to add the scale. The problem is that gtable_frame2 puts all of the facets into a single cell, so when we add the scale, it just puts it below that entire cell (across all facet columns). The best thing to do would probably treat each facet as it's own cell. Then we can put the scale under each cell (and beyond that, we could make it such that it only puts the scale if there is an axis for that cell).

Blank box when axis cross 0

p <- ggplot() +
    geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 50))) +
    coord_cartesian(xlim = c(-5, 50), ylim = c(0,8), expand = FALSE) +
    theme_classic()
gggeo_scale(p)

image

Write tests

Ideally we would have tests to make sure nothing is breaking when new changes are made.

ggsave bug

Hi Will, I've been using deeptime to create figures then saving them using ggsave. Today I tried remaking some, and although they appear as normal in the plot viewer in RStudio, when exported using ggsave the axis takes up the whole plot (see below). Do you know if this is a bug or I need to update my code in some way?
bd_extinction_new.pdf

Can't stack multiple scales

This example no longer works since the switch from annotate to geom_rect:

p <- ggplot() +
  geom_point(aes(y = runif(1000, 1, 8), x = runif(1000, 0, 1000))) +
  scale_x_reverse() +
  coord_cartesian(xlim = c(0, 100), ylim = c(0,8), expand = FALSE) +
  theme_classic()
p <- gggeo_scale(p, height = .03, abbrv = FALSE)
p <- gggeo_scale(p, dat = "epochs", gap = .03, height = .1, rot = 90, size = 3)
gggeo_scale(p, dat = "stages", gap = .13, height = .1, rot = 90, size = 3)

I guess I'll need a way to figure out if there's already a fill_geo_scale and changed the name of the next fill aes? Or maybe I really SHOULD switch to ggnewscale, since that will switch to a new fill each time the function is called.

`pos` order is inconsistent for different sides

No one has complained about this (yet), but it looks like the behavior of the pos argument is different for whichever side you are specifying.

For example, for the bottom axis, the scales are added from the plot outwards:

ggplot() +
    geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 100))) +
    scale_x_reverse() +
    coord_geo(
        xlim = c(100, 0), ylim = c(0, 8), pos = as.list(rep("bottom", 3)),
        dat = list("stages", "epochs", "periods"),
        height = list(unit(4, "lines"), unit(4, "lines"), unit(2, "line")),
        rot = list(90, 90, 0), size = list(2.5, 2.5, 5), abbrv = FALSE
    ) +
    theme_classic()

image

But for the top axis, the scales are added from the outside inwards:

ggplot() +
    geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 100))) +
    scale_x_reverse() +
    coord_geo(
        xlim = c(100, 0), ylim = c(0, 8), pos = as.list(rep("top", 3)),
        dat = list("stages", "epochs", "periods"),
        height = list(unit(4, "lines"), unit(4, "lines"), unit(2, "line")),
        rot = list(90, 90, 0), size = list(2.5, 2.5, 5), abbrv = FALSE
    ) +
    theme_classic()

image

The same is true for left (inside outwards) and right (outside inwards) scales.

Feature request: enable choosing 'expand' for Y or X axis

In my plot, I am using position_dodge to separate (jitter) points within a category along the Y axis. I like the way the current X axis is set up, so I don't want to change the expansion for that. But I want to use expand = TRUE in coord_geo() so I can add a buffer at either end of the Y axis so my jittered points near the plot edge still show up.

Currently the expand argument seems to affect both axes, without an option to choose one or the other. How about splitting this up into expand.x and expand.y or similar?

Thanks!

Scale disappears when scale breaks are reversed

When the breaks in a scale are in the reverse order as expected by the axis, the scale no longer appears:

library(phytools)
library(ggtree)
library(paleotree)
data(RaiaCopesRule)
ggtree(ceratopsianTreeRaia, position = position_nudge(x = -ceratopsianTreeRaia$root.time)) +
  coord_geo(xlim = c(-163.5,-66), ylim = c(-2,Ntip(ceratopsianTreeRaia)), pos = list("bottom", "bottom"),
            skip = c("Paleocene", "Middle Jurassic"), dat = list("epochs", "periods"), abbrv = FALSE,
            size = list(4,5), neg = TRUE, center_end_labels = TRUE) +
  scale_x_continuous(breaks = -epochs$max_age, labels = epochs$max_age) +
  theme_tree2()

image

But the following works:

ggtree(ceratopsianTreeRaia, position = position_nudge(x = -ceratopsianTreeRaia$root.time)) +
  coord_geo(xlim = c(-163.5,-66), ylim = c(-2,Ntip(ceratopsianTreeRaia)), pos = list("bottom", "bottom"),
            skip = c("Paleocene", "Middle Jurassic"), dat = list("epochs", "periods"), abbrv = FALSE,
            size = list(4,5), neg = TRUE, center_end_labels = TRUE) +
  scale_x_continuous(breaks = -rev(epochs$max_age), labels = rev(epochs$max_age)) +
  theme_tree2()

coord_trans_xy() doesn't update axis ticks/labels

When using coord_trans_xy(), the axis ticks and labels are not updated to reflect the transformation. (This is only apparent when the transformation is large, but not when it is small like in the README)

library(ggforce)

trans <- linear_trans(shear(2, 0), rotate(-pi / 3))
square <- data.frame(x = c(0, 0, 4, 4), y = c(0, 1, 1, 0))
points <- data.frame(x = rep(seq(0, 4, 0.2), each = 6), y = rep(seq(0, 1, 0.2), 21))
ggplot(data = points, aes(x = x, y = y)) +
  geom_polygon(data = square, fill = NA, color = "black") +
  geom_point(color = 'black') +
  coord_trans_xy(trans = trans, expand = FALSE) +
  theme_classic()

image

gtable_frame2 removes margins

When a plot goes through gtable_frame2, it appears to lose the margins that were set for the plot. This can be a problem when you are combining plots with ggarrange2, because the plots can essentially touch each other.

coord_geo_polar labels

Is it possible to neatly add labels as part of coord_geo_polar? Or should that be left to the user?

geoms with their own data don't work with ggtree

Had everything working beautifully a few days ago, now I go to try to run the script and something is not working.

>tree<-pbtree(n=16,tip.label=LETTERS[1:16],scale=20)
>p <- ggtree(tree, size = 0.3) + 
  coord_cartesian(xlim = c(15,-30), ylim = c(-40,Ntip(tree)), expand = FALSE) +
  scale_x_continuous(breaks=seq(-30,0,10), labels=abs(seq(-30,0,10))) +
  geom_tiplab(cex = 0.7) +
  theme_tree2()
>p <- revts(p)
>p <- gggeo_scale(p, height = .03, abbrv = FALSE, neg = TRUE)
Ignoring unknown aesthetics: fill_geo_scale
>p
Error in FUN(X[[i]], ...) : object 'y' not found

Traceback yields

10. FUN(X[[i]], ...) 
9. lapply(aesthetics, rlang::eval_tidy, data = data) 
8. f(..., self = self) 
7. l$compute_aesthetics(d, plot) 
6. f(l = layers[[i]], d = data[[i]]) 
5. by_layer(function(l, d) l$compute_aesthetics(d, plot)) 
4. ggplot_build.ggplot(x) 
3. ggplot_build(x) 
2. print.ggplot(x) 
1. function (x, ...) UseMethod("print")(x)

So my guess is that it is failing because it is not able to find fill_geo_scale.
Curiously, in a second script, the error is "object 'x' not found", but I presume it is caused by the same problem.

missing argument using gggeo_scale

I installed the package just as suggested in the readme file. Then I tried to replicate the examples on readme file

at

p <- ggplot() + geom_point(aes(x = runif(1000, 0, 8), y = runif(1000, 0, 541))) + scale_y_reverse() + coord_cartesian(xlim = c(0, 8), ylim = c(0,541), expand = FALSE) + theme_classic() gggeo_scale_old(p, pos = "left", rot = 90)

I got the error message

Error in gggeo_scale(p, pos = "left", rot = 90) : unused argument (rot = 90)

When I used the gggeo_scale_old function the error message did not appear.

Running R version 3.6.1 on Ubuntu 18.04 via RStudio.

Best wishes,
Mario

Error when axis breaks are NULL

When the breaks for an axis are set to NULL (e.g. scale_x_continuous(breaks = NULL)), it results in the following error:

Error in if (bord_lims[1] == lims[1]) lwd * 2 else lwd : 
  missing value where TRUE/FALSE needed

Questions about deeptime one tree (tiplabel & grey/white colors)

Hello, first of all thank you very much for the development of this package, it will be useful for many people.

I just have some questions about the tutorial:

data(mammal.tree)
p <- ggtree(mammal.tree) +
  coord_geo(xlim = c(-75,0), ylim = c(-2,Ntip(mammal.tree)), neg = TRUE, abbrv = FALSE) +
  scale_x_continuous(breaks=seq(-80,0,20), labels=abs(seq(-80,0,20))) +
  theme_tree2()
revts(p)

With that tutorial we are able to draw this figure:

Capture d’écran 2021-09-14 à 09 33 12

Here I my 2 questions:

  • Is it possible to add tiplabel ? I tried with the ggtree function geom_tiplab() but It does not work.
  • Is it possible as in the following figure:

Capture d’écran 2021-09-14 à 09 35 55

to add between each geological period a grey and blank colors ?

Thanks a lot and have a nice day.

coord_geo_discrete()

It would be great if you could use coord_geo with a discrete scale for boxplots, etc..

Use real data for examples

I think it would be more useful (and more aesthetically pleasing) if the data used for all of the examples (both in the readme and in the man pages) was real data (or "real" data) as opposed to just random points ("a swarm of angry bees" as one user mentioned to me on twitter).

facet strips with GTS colors

@LewisAJones suggests that I implement a way to have the background colors of facet strips based on the colors from the GTS. I have code to do this with gtable (very simple), but it's also possible I could coopt some functions from the ggh4x package or coopt some of the source code from the package to make it happen without converting to a gtable.

Problems when x axis crosses 0

If you have your x axis overlap with 0, it can cause the scale to be incorrectly flipped:

p <- ggplot() +
    geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 1000))) +
    coord_cartesian(xlim = c(-5, 1000), ylim = c(0,8), expand = FALSE) +
    theme_classic()
gggeo_scale(p)

But perhaps this is more of a problem when expand = TRUE (the default):

p <- ggplot() +
    geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 1000))) +
    coord_cartesian(xlim = c(0, 1000), ylim = c(0,8)) +
    theme_classic()
gggeo_scale(p)

The problem stems from the assumption that if any x.range value is negative, the whole axis must be flipped:

rev_axis <- any(lims$x.range < 0)

I guess I'll need a more robust way of testing if the x axis is reversed.

It also trims the scale due to the assumption in this line:

coord_cartesian(xlim = abs(lims$x.range), expand = FALSE)

A nonsensical but exemplar case of this problem results from this:

p <- ggplot() +
    geom_point(aes(y = runif(1000, 0, 8), x = runif(1000, 0, 1000))) +
    scale_x_reverse() +
    coord_cartesian(xlim = c(-1000, 1000), ylim = c(0,8)) +
    theme_classic()
gggeo_scale(p)

Custom theme elements

I feel like this shouldn't be too difficult. Just need a way to pass a list of theme elements to theme().

How to set color of text in labels?

Thanks for the great package!

Is there a way to specify the color of the text (ie, the font color) in the labels? I see there are options for fill color (fill) and outline color (color) in coord_geo() but I couldn't find anything for the text.

coord_trans_xy breaks axis tick labels

I'm not quite sure when this happened, but a change with ggplot must have caused coord_trans_xy to break.
This example works, but results in the tick labels all getting bunched up at the lower left corner:

#make transformer
library(ggforce)
trans <- linear_trans(shear(2, 0))

#set up data to be plotted
square <- data.frame(x = c(0, 0, 4, 4), y = c(0, 1, 1, 0))
points <- data.frame(x = runif(100, 0, 4), y = runif(100, 0, 1), group = rep(1:5, each = 20))

ggplot(data = points, aes(x = x, y = y)) +
  geom_polygon(data = square, fill = NA, color = "black") +
  geom_point(color = 'black') +
  coord_trans_xy(trans = trans, expand = FALSE) +
  theme_classic() +
  facet_wrap(~group, ncol = 1, strip.position = "right") +
  theme(panel.spacing = unit(0, "lines"), panel.background = element_blank())

There are several warning messages:
Position guide is perpendicular to the intended axis. Did you mean to specify a different guide `position`?

Auto-abbreviate text if there is too less space

Is there a way to automatically abbreviate text elements depending on the space that is available on the plot? i.e. if the text element exceeds the dimensions of the rectangle in which it is centered.

geo_scale_colour and geo_scale_fill

Hi Will,

deeptime has some great functionality for helping to add the geological timescale to a ggplot plot. I was wondering if functionality could be expanded to include a geo_scale_colour and geo_scale_fill (similar to scale_colour_manual)? I think this would be a great visualisation tool and could neatly add a third dimension to variable comparison plots.

Best,

Lewis

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.