Code Monkey home page Code Monkey logo

Comments (5)

jhaynes avatar jhaynes commented on July 18, 2024

Doing something like this works... but produces a blank plot first... haven't sorted out why.

class geom_boxplot(geom):
    VALID_AES = ['y', 'lower','middle','upper','x','ymax','ymin','alpha',
                 'colour','color','fill','linetype','shape','size','weight']


    def plot_layer(self, layer):
        layer = {k: v for k, v in layer.items() if k in self.VALID_AES}
        layer.update(self.manual_aes)

        # Option 1 (No Pandas)

        # Boxplot takes in an array or sequence of vectors
        # The goal is to group the 'y' values by grouped 'x'
        # Then take the transpose and give it to plt.boxplot(**layer)
        # If we do not have a y value, no need to change anything
        #        if "y" in layer:
        # list(set([...])) just gets unique elements
        #           unique = list(set(layer["x"]))            
        # Group y values in len(x) arrays, having values y.x
        # Store it back in x as a transpose.            
        #          pass

        # plt.boxplot(**layer)
        # Option 2 With Pandas and DataFrame.boxplot()
        # Need access to the DataFrame passed to ggplot(..)
        df = DataFrame({'y': layer['y']})
        if 'x' in layer:
            layer['by'] = 'x'
            df['x'] = layer['x']
            del layer['x']
        if 'y' in layer:
            layer['column'] = 'y'
            del layer['y']
        df.boxplot(**layer)

from ggpy.

glamp avatar glamp commented on July 18, 2024

take a look at how geom_bar works. i think you can piggy-back off of that.

from ggpy.

jhaynes avatar jhaynes commented on July 18, 2024

Thanks, geom_bar looks like a good place to start and avoiding deep coupling with pandas is probably not a terrible idea.

This is sort off topic, but is there a reason why you opted to pass the values from aes around rather than the data frame and its column names?

from ggpy.

glamp avatar glamp commented on July 18, 2024

Largely b/c the geoms have aes defined on an individual basis. That said, I don't think theres any reason data frames wouldn't work.

On Oct 25, 2013, at 9:38 AM, jhaynes [email protected] wrote:
Thanks, geom_bar looks like a good place to start and avoiding deep coupling with pandas is probably not a terrible idea.

This is sort off topic, but is there a reason why you opted to pass the values from aes around rather than the data frame and its column names?


Reply to this email directly or view it on GitHub.

from ggpy.

glamp avatar glamp commented on July 18, 2024

thanks to @JanSchulz for this one!

from ggpy.

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.