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;
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:
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
add a comment |
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:
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
can you include sample data?
– josemz
Mar 22 at 19:00
add a comment |
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:
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
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:
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
python dataframe matplotlib seaborn
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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)
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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)
add a comment |
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)
add a comment |
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)
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)
edited Mar 22 at 19:40
answered Mar 22 at 19:30
NathanielNathaniel
2,220214
2,220214
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
can you include sample data?
– josemz
Mar 22 at 19:00