Reproducing plot in R using ggplot (Area plot)Plot two graphs in same plot in RHow to set limits for axes in ggplot2 R plots?How to make a great R reproducible exampleMinimize drawing size of ggplot plots by ignoring zero-length variablesSave plot to image file instead of displaying it using MatplotlibPlotting confidence intervals in ggplotPlot temporal tag coverage with ggplotColoring boxplot columns in ggplot in a repeating patternPlot a Linear Regression in ggplot2Passing a function to the ggplot density plot

Asking bank to reduce APR instead of increasing credit limit

Double integral bounds of integration polar change of coordinate

'chmod' would set file permission to 000 no matter what permission I try to set

Order by does not work as I expect

Is there a way to save this session?

Where can I find the list of all tendons in the human body?

Creating Fictional Slavic Place Names

Can a non-EU citizen travel freely within the Schengen area without passport?

Can a helicopter mask itself from Radar?

Can I ask a publisher for a paper that I need for reviewing

How can I offer a test ride while selling a bike?

Is this light switch installation safe and legal?

How does increase in volume change the speed of reaction in production of NO2?

What is a simple, physical situation where complex numbers emerge naturally?

Can you use a concentration spell while using Mantle of Majesty?

How can I stop my presentation being derailed by audience questions?

Future enhancements for the finite element method

Can you dispel the Slow effect of a Stone Golem?

Are there regional foods in Westeros?

Why would Lupin kill Pettigrew?

What is the intuition behind uniform continuity?

Can a rogue effectively triple their speed by combining Dash and Ready?

When was the word "ambigu" first used with the sense of "meal with all items served at the same time"?

How was Apollo supposed to rendezvous in the case of a lunar abort?



Reproducing plot in R using ggplot (Area plot)


Plot two graphs in same plot in RHow to set limits for axes in ggplot2 R plots?How to make a great R reproducible exampleMinimize drawing size of ggplot plots by ignoring zero-length variablesSave plot to image file instead of displaying it using MatplotlibPlotting confidence intervals in ggplotPlot temporal tag coverage with ggplotColoring boxplot columns in ggplot in a repeating patternPlot a Linear Regression in ggplot2Passing a function to the ggplot density plot






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm trying to reproduce a plot in R where I have the data but not the code.
I think using ggplot will be the best solution.



The plot should look like this:



Click



My data:



A dataframe (d) where column 1 ("Year") gives the year (1960 - 2000) and 15 other columns ("Group 1", "Group 2"...) giving the value of the group. Thus, each row contains the year and the values for the certain group.
(e.g. (1) 1960; 455; 367; 477; 788; 456; 334; 456;...)



I already tried some experiments with geom_area, but this does not result in the intendet graph.



ggplot(d, aes(x = Year, y = d[,2]))+
geom_area(fill = "#00AFBB", color = "blue")


Here I get n (n = # of Years) very thin bars representing the value of group 1 against a certain year.



Hope you can help me out maybe with some ideas or a tutorial. Is area plot the right choice for what I want to do?



Best!










share|improve this question






























    0















    I'm trying to reproduce a plot in R where I have the data but not the code.
    I think using ggplot will be the best solution.



    The plot should look like this:



    Click



    My data:



    A dataframe (d) where column 1 ("Year") gives the year (1960 - 2000) and 15 other columns ("Group 1", "Group 2"...) giving the value of the group. Thus, each row contains the year and the values for the certain group.
    (e.g. (1) 1960; 455; 367; 477; 788; 456; 334; 456;...)



    I already tried some experiments with geom_area, but this does not result in the intendet graph.



    ggplot(d, aes(x = Year, y = d[,2]))+
    geom_area(fill = "#00AFBB", color = "blue")


    Here I get n (n = # of Years) very thin bars representing the value of group 1 against a certain year.



    Hope you can help me out maybe with some ideas or a tutorial. Is area plot the right choice for what I want to do?



    Best!










    share|improve this question


























      0












      0








      0








      I'm trying to reproduce a plot in R where I have the data but not the code.
      I think using ggplot will be the best solution.



      The plot should look like this:



      Click



      My data:



      A dataframe (d) where column 1 ("Year") gives the year (1960 - 2000) and 15 other columns ("Group 1", "Group 2"...) giving the value of the group. Thus, each row contains the year and the values for the certain group.
      (e.g. (1) 1960; 455; 367; 477; 788; 456; 334; 456;...)



      I already tried some experiments with geom_area, but this does not result in the intendet graph.



      ggplot(d, aes(x = Year, y = d[,2]))+
      geom_area(fill = "#00AFBB", color = "blue")


      Here I get n (n = # of Years) very thin bars representing the value of group 1 against a certain year.



      Hope you can help me out maybe with some ideas or a tutorial. Is area plot the right choice for what I want to do?



      Best!










      share|improve this question
















      I'm trying to reproduce a plot in R where I have the data but not the code.
      I think using ggplot will be the best solution.



      The plot should look like this:



      Click



      My data:



      A dataframe (d) where column 1 ("Year") gives the year (1960 - 2000) and 15 other columns ("Group 1", "Group 2"...) giving the value of the group. Thus, each row contains the year and the values for the certain group.
      (e.g. (1) 1960; 455; 367; 477; 788; 456; 334; 456;...)



      I already tried some experiments with geom_area, but this does not result in the intendet graph.



      ggplot(d, aes(x = Year, y = d[,2]))+
      geom_area(fill = "#00AFBB", color = "blue")


      Here I get n (n = # of Years) very thin bars representing the value of group 1 against a certain year.



      Hope you can help me out maybe with some ideas or a tutorial. Is area plot the right choice for what I want to do?



      Best!







      r ggplot2 plot graphics data-visualization






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 11:08









      kath

      5,0911026




      5,0911026










      asked Mar 24 at 11:04









      MarlMarl

      31




      31






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You need to convert the data from wide to long format and then it should work:



          library(dplyr)
          library(tidyr)
          library(ggplot2)
          d <- gather(d, Group, value, Group1:Group15)
          ggplot(d, aes(x = Year, y = value, fill = Group))+
          geom_area()





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55323137%2freproducing-plot-in-r-using-ggplot-area-plot%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You need to convert the data from wide to long format and then it should work:



            library(dplyr)
            library(tidyr)
            library(ggplot2)
            d <- gather(d, Group, value, Group1:Group15)
            ggplot(d, aes(x = Year, y = value, fill = Group))+
            geom_area()





            share|improve this answer



























              0














              You need to convert the data from wide to long format and then it should work:



              library(dplyr)
              library(tidyr)
              library(ggplot2)
              d <- gather(d, Group, value, Group1:Group15)
              ggplot(d, aes(x = Year, y = value, fill = Group))+
              geom_area()





              share|improve this answer

























                0












                0








                0







                You need to convert the data from wide to long format and then it should work:



                library(dplyr)
                library(tidyr)
                library(ggplot2)
                d <- gather(d, Group, value, Group1:Group15)
                ggplot(d, aes(x = Year, y = value, fill = Group))+
                geom_area()





                share|improve this answer













                You need to convert the data from wide to long format and then it should work:



                library(dplyr)
                library(tidyr)
                library(ggplot2)
                d <- gather(d, Group, value, Group1:Group15)
                ggplot(d, aes(x = Year, y = value, fill = Group))+
                geom_area()






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 24 at 11:27









                SonnySonny

                2,6241516




                2,6241516





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55323137%2freproducing-plot-in-r-using-ggplot-area-plot%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript