Giter Site home page Giter Site logo

ggplot2 syntax changes about rgbif HOT 10 CLOSED

ropensci avatar ropensci commented on May 21, 2024
ggplot2 syntax changes

from rgbif.

Comments (10)

karthik avatar karthik commented on May 21, 2024

Also, it would be great to allow people to manipulate the plot the way they choose. So add a ... argument to the outer function and pass it on to ggplot.

from rgbif.

sckott avatar sckott commented on May 21, 2024

Pointtype and jitter fixed.

The problem I'm having with passing options into the function is that I don't want the options passed in to override all of the options we specify within the function. For example, in our block of code for plotting:

ggplot(world, aes(long, lat)) + # make the plot
    geom_polygon(aes(group=group), fill="white", color="gray40", size=0.2) +
    geom(data=tomap, aes(decimalLongitude, decimalLatitude, colour=taxonName), 
         alpha=0.4, size=3, position=jitter) +
    labs(x="", y="") +
    theme_bw(base_size=14)

where would we allow users to pass in different options? We could let people do something like specify a set of ggplot options in a function, then pass it in to gbifmap

mycustom <- function(){
    list(geom_point(size=9), 
              etc....)
}
out <- occurrencelist(scientificname = 'Accipiter erythronemius', coordinatestatus = TRUE, maxresults = 100)
gbifmap( out,  customize = mycustom() )

And then modify our above plotting block to add whatever options the user wants

ggplot(world, aes(long, lat)) + # make the plot
    geom_polygon(aes(group=group), fill="white", color="gray40", size=0.2) +
    geom(data=tomap, aes(decimalLongitude, decimalLatitude, colour=taxonName), 
         alpha=0.4, size=3, position=jitter) +
    labs(x="", y="") +
    theme_bw(base_size=14) +
    customize

But then the user options override the previous options in the ggplot code block

from rgbif.

karthik avatar karthik commented on May 21, 2024

I just realized that this is a non-issue. Once a ggplot2 object is returned, anyone can override your settings or add more. For example, I could do a + geom_point(size = 14) and it will override the one inside. So we can just tell users that they can customize however they like after the fact (no need to pass arguments via the function call).

from rgbif.

sckott avatar sckott commented on May 21, 2024

not sure that's true. If you do geom_point(size = 14) then the geom(data=tomap, aes(decimalLongitude, decimalLatitude, colour=taxonName), alpha=0.4, size=3, position=jitter) code is ignored, and screws up the plot.

from rgbif.

karthik avatar karthik commented on May 21, 2024

Hmm. See this question for reference: http://stackoverflow.com/questions/13831717/how-does-one-pass-additional-parameters-to-a-ggplot-generated-inside-a-function/13832162#13832162

Perhaps we should work on this some more to make the theme part general but not break core functionality.

On Wednesday, December 12, 2012 at 11:47 AM, Scott Chamberlain wrote:

not sure that's true. If you do geom_point(size = 14) then the geom(data=tomap, aes(decimalLongitude, decimalLatitude, colour=taxonName), alpha=0.4, size=3, position=jitter) code is ignored, and screws up the plot.

โ€”
Reply to this email directly or view it on GitHub (#11 (comment)).

from rgbif.

karthik avatar karthik commented on May 21, 2024

Another bug, the legend should show up even if there is only one species. Don't you agree? If so I can code that fix.

from rgbif.

sckott avatar sckott commented on May 21, 2024

I tend to not think so, but perhaps it makes sense for greater consistency in map output

from rgbif.

karthik avatar karthik commented on May 21, 2024

scratch that. You are right. plots with only one type don't need legends.

On Wednesday, December 12, 2012 at 2:18 PM, Scott Chamberlain wrote:

I tend to not think so, but perhaps it makes sense for greater consistency in map output

โ€”
Reply to this email directly or view it on GitHub (#11 (comment)).

from rgbif.

sckott avatar sckott commented on May 21, 2024

okay, cool

from rgbif.

sckott avatar sckott commented on May 21, 2024

think this is done

from rgbif.

Related Issues (20)

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.