How to plot 2 graphs using seaborn in Python 3.6?How to merge two dictionaries in a single expression?How do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?

What are the potential pitfalls when using metals as a currency?

Is the 5 MB static resource size limit 5,242,880 bytes or 5,000,000 bytes?

Pass By Reference VS Pass by Value

Is there really no use for MD5 anymore?

How can I practically buy stocks?

Is DC-DC (24v to 12v) Buck Conversion typically more efficient than AC-DC (110v to 12v) conversion?

Why do Computer Science majors learn Calculus?

Binary Numbers Magic Trick

Which big number is bigger?

What is the difference between `command a[bc]d` and `command `ab,cd`

a sore throat vs a strep throat vs strep throat

Realistic Necromancy?

How much cash can I safely carry into the USA and avoid civil forfeiture?

Please, smoke with good manners

Was is really necessary for the Lunar module LM to have 2 stages?

Examples of subgroups where it's nontrivial to show closure under multiplication?

How to get a plain text file version of a CP/M .BAS (M-BASIC) program?

Critique of timeline aesthetic

Error message with tabularx

Why isn't the definition of absolute value applied when squaring a radical containing a variable?

Do I have to worry about players making “bad” choices on level up?

How to make a pipeline wait for end-of-file or stop after an error?

How come there are so many candidates for the 2020 Democratic party presidential nomination?

Fizzy, soft, pop and still drinks



How to plot 2 graphs using seaborn in Python 3.6?


How to merge two dictionaries in a single expression?How do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?






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








0















I want the first subplot to only include 'Máximo', 'Média', 'Mínimo', and the second to only include 'Amplitude', 'Desvio Padrão'.



I tried the following:



def plotGraph(title, z): #Todo Completar a função com legendas e título.
sns.set()
fig, ax = plt.subplots(2,1)
sns.lineplot(data=z, hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
sns.lineplot(data=z, hue=['Amplitude', 'Desvio Padrão'], ax=ax[1])
plt.show()


But got this:
image



I know I can make this with multiple calls using plt.plot(), but is there a way to do with seaborn?



 **EDITED**


thanks, but I realized I don't need 'Desvio Padrão'. Is there a way to just legend 'Amplitude' ?



def plotGraph(title, df): #Todo Completar a função com legendas e título.
sns.set()
fig, ax = plt.subplots(2,1)
fig.suptitle(title)
sns.lineplot(data=df[['Máximo', 'Média', 'Mínimo']], hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
sns.lineplot(data=df['Amplitude'], hue='Amplitude', ax=ax[1], legend='full')
fig.tight_layout(rect=[0.01, 0.01, 0.95, 0.95]) # Controla o tamanho dos gŕaficos na figura (valores entre 0 e 1).
plt.show()


enter image description here










share|improve this question
























  • can you include sample data?

    – josemz
    Mar 22 at 19:00

















0















I want the first subplot to only include 'Máximo', 'Média', 'Mínimo', and the second to only include 'Amplitude', 'Desvio Padrão'.



I tried the following:



def plotGraph(title, z): #Todo Completar a função com legendas e título.
sns.set()
fig, ax = plt.subplots(2,1)
sns.lineplot(data=z, hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
sns.lineplot(data=z, hue=['Amplitude', 'Desvio Padrão'], ax=ax[1])
plt.show()


But got this:
image



I know I can make this with multiple calls using plt.plot(), but is there a way to do with seaborn?



 **EDITED**


thanks, but I realized I don't need 'Desvio Padrão'. Is there a way to just legend 'Amplitude' ?



def plotGraph(title, df): #Todo Completar a função com legendas e título.
sns.set()
fig, ax = plt.subplots(2,1)
fig.suptitle(title)
sns.lineplot(data=df[['Máximo', 'Média', 'Mínimo']], hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
sns.lineplot(data=df['Amplitude'], hue='Amplitude', ax=ax[1], legend='full')
fig.tight_layout(rect=[0.01, 0.01, 0.95, 0.95]) # Controla o tamanho dos gŕaficos na figura (valores entre 0 e 1).
plt.show()


enter image description here










share|improve this question
























  • can you include sample data?

    – josemz
    Mar 22 at 19:00













0












0








0








I want the first subplot to only include 'Máximo', 'Média', 'Mínimo', and the second to only include 'Amplitude', 'Desvio Padrão'.



I tried the following:



def plotGraph(title, z): #Todo Completar a função com legendas e título.
sns.set()
fig, ax = plt.subplots(2,1)
sns.lineplot(data=z, hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
sns.lineplot(data=z, hue=['Amplitude', 'Desvio Padrão'], ax=ax[1])
plt.show()


But got this:
image



I know I can make this with multiple calls using plt.plot(), but is there a way to do with seaborn?



 **EDITED**


thanks, but I realized I don't need 'Desvio Padrão'. Is there a way to just legend 'Amplitude' ?



def plotGraph(title, df): #Todo Completar a função com legendas e título.
sns.set()
fig, ax = plt.subplots(2,1)
fig.suptitle(title)
sns.lineplot(data=df[['Máximo', 'Média', 'Mínimo']], hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
sns.lineplot(data=df['Amplitude'], hue='Amplitude', ax=ax[1], legend='full')
fig.tight_layout(rect=[0.01, 0.01, 0.95, 0.95]) # Controla o tamanho dos gŕaficos na figura (valores entre 0 e 1).
plt.show()


enter image description here










share|improve this question
















I want the first subplot to only include 'Máximo', 'Média', 'Mínimo', and the second to only include 'Amplitude', 'Desvio Padrão'.



I tried the following:



def plotGraph(title, z): #Todo Completar a função com legendas e título.
sns.set()
fig, ax = plt.subplots(2,1)
sns.lineplot(data=z, hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
sns.lineplot(data=z, hue=['Amplitude', 'Desvio Padrão'], ax=ax[1])
plt.show()


But got this:
image



I know I can make this with multiple calls using plt.plot(), but is there a way to do with seaborn?



 **EDITED**


thanks, but I realized I don't need 'Desvio Padrão'. Is there a way to just legend 'Amplitude' ?



def plotGraph(title, df): #Todo Completar a função com legendas e título.
sns.set()
fig, ax = plt.subplots(2,1)
fig.suptitle(title)
sns.lineplot(data=df[['Máximo', 'Média', 'Mínimo']], hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
sns.lineplot(data=df['Amplitude'], hue='Amplitude', ax=ax[1], legend='full')
fig.tight_layout(rect=[0.01, 0.01, 0.95, 0.95]) # Controla o tamanho dos gŕaficos na figura (valores entre 0 e 1).
plt.show()


enter image description here







python dataframe matplotlib seaborn






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 22:13







João Vitor Barbosa

















asked Mar 22 at 18:35









João Vitor BarbosaJoão Vitor Barbosa

12




12












  • can you include sample data?

    – josemz
    Mar 22 at 19:00

















  • can you include sample data?

    – josemz
    Mar 22 at 19:00
















can you include sample data?

– josemz
Mar 22 at 19:00





can you include sample data?

– josemz
Mar 22 at 19:00












1 Answer
1






active

oldest

votes


















1














You need to subset the data frame to include only the columns you want to plot:



import pandas as pd
import numpy as np; np.random.seed(0)
import matplotlib.pyplot as plt
import seaborn as sns
import cufflinks as cf

# Generate sample data
df = cf.datagen.lines(5)
df.columns = ['Máximo', 'Média', 'Mínimo', 'Amplitude', 'Desvio Padrão']
df = df.reset_index(drop=True)

def plotGraph(title, z):
sns.set()
fig, ax = plt.subplots(2,1)
fig.suptitle(title)
sns.lineplot(data=z[['Máximo', 'Média', 'Mínimo']], hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
sns.lineplot(data=z[['Amplitude', 'Desvio Padrão']], hue=['Amplitude', 'Desvio Padrão'], ax=ax[1])
fig.tight_layout(rect=[0, 0.03, 1, 0.95])
plt.show()

plotGraph('Plot Title', df)


Plot






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%2f55305897%2fhow-to-plot-2-graphs-using-seaborn-in-python-3-6%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









    1














    You need to subset the data frame to include only the columns you want to plot:



    import pandas as pd
    import numpy as np; np.random.seed(0)
    import matplotlib.pyplot as plt
    import seaborn as sns
    import cufflinks as cf

    # Generate sample data
    df = cf.datagen.lines(5)
    df.columns = ['Máximo', 'Média', 'Mínimo', 'Amplitude', 'Desvio Padrão']
    df = df.reset_index(drop=True)

    def plotGraph(title, z):
    sns.set()
    fig, ax = plt.subplots(2,1)
    fig.suptitle(title)
    sns.lineplot(data=z[['Máximo', 'Média', 'Mínimo']], hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
    sns.lineplot(data=z[['Amplitude', 'Desvio Padrão']], hue=['Amplitude', 'Desvio Padrão'], ax=ax[1])
    fig.tight_layout(rect=[0, 0.03, 1, 0.95])
    plt.show()

    plotGraph('Plot Title', df)


    Plot






    share|improve this answer





























      1














      You need to subset the data frame to include only the columns you want to plot:



      import pandas as pd
      import numpy as np; np.random.seed(0)
      import matplotlib.pyplot as plt
      import seaborn as sns
      import cufflinks as cf

      # Generate sample data
      df = cf.datagen.lines(5)
      df.columns = ['Máximo', 'Média', 'Mínimo', 'Amplitude', 'Desvio Padrão']
      df = df.reset_index(drop=True)

      def plotGraph(title, z):
      sns.set()
      fig, ax = plt.subplots(2,1)
      fig.suptitle(title)
      sns.lineplot(data=z[['Máximo', 'Média', 'Mínimo']], hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
      sns.lineplot(data=z[['Amplitude', 'Desvio Padrão']], hue=['Amplitude', 'Desvio Padrão'], ax=ax[1])
      fig.tight_layout(rect=[0, 0.03, 1, 0.95])
      plt.show()

      plotGraph('Plot Title', df)


      Plot






      share|improve this answer



























        1












        1








        1







        You need to subset the data frame to include only the columns you want to plot:



        import pandas as pd
        import numpy as np; np.random.seed(0)
        import matplotlib.pyplot as plt
        import seaborn as sns
        import cufflinks as cf

        # Generate sample data
        df = cf.datagen.lines(5)
        df.columns = ['Máximo', 'Média', 'Mínimo', 'Amplitude', 'Desvio Padrão']
        df = df.reset_index(drop=True)

        def plotGraph(title, z):
        sns.set()
        fig, ax = plt.subplots(2,1)
        fig.suptitle(title)
        sns.lineplot(data=z[['Máximo', 'Média', 'Mínimo']], hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
        sns.lineplot(data=z[['Amplitude', 'Desvio Padrão']], hue=['Amplitude', 'Desvio Padrão'], ax=ax[1])
        fig.tight_layout(rect=[0, 0.03, 1, 0.95])
        plt.show()

        plotGraph('Plot Title', df)


        Plot






        share|improve this answer















        You need to subset the data frame to include only the columns you want to plot:



        import pandas as pd
        import numpy as np; np.random.seed(0)
        import matplotlib.pyplot as plt
        import seaborn as sns
        import cufflinks as cf

        # Generate sample data
        df = cf.datagen.lines(5)
        df.columns = ['Máximo', 'Média', 'Mínimo', 'Amplitude', 'Desvio Padrão']
        df = df.reset_index(drop=True)

        def plotGraph(title, z):
        sns.set()
        fig, ax = plt.subplots(2,1)
        fig.suptitle(title)
        sns.lineplot(data=z[['Máximo', 'Média', 'Mínimo']], hue=['Máximo', 'Média', 'Mínimo'], ax=ax[0])
        sns.lineplot(data=z[['Amplitude', 'Desvio Padrão']], hue=['Amplitude', 'Desvio Padrão'], ax=ax[1])
        fig.tight_layout(rect=[0, 0.03, 1, 0.95])
        plt.show()

        plotGraph('Plot Title', df)


        Plot







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 22 at 19:40

























        answered Mar 22 at 19:30









        NathanielNathaniel

        2,220214




        2,220214





























            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%2f55305897%2fhow-to-plot-2-graphs-using-seaborn-in-python-3-6%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