Seaborn scatterplot addition legend items












3














I'm seeing '1 and 2' as additional labels in my legend for a seaborn scatterplot. They'll disappear when I set the legend to False, but so does the legend I do want in there.
Any idea where this comes from and how to prevent it from appearing?



This sample code generates the image with the issue;



import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

df = pd.DataFrame({'restHR': np.random.randint(40,65, size=(100,)),
'Time': np.random.randint(0,10, size=(100,))})

sns.set()
fig, ax = plt.subplots()

ax = sns.scatterplot(df['Time'], df['restHR'], size=2, alpha=0.3, label="Race",linewidths=0)

plt.legend(frameon=False, bbox_to_anchor=(1,0.5), loc="center left",prop={'size': 8})
plt.subplots_adjust(right=0.75)

plt.show()


enter image description here










share|improve this question






















  • What is the purpose of size=2? Usually you would do size="columnname" to group sizes. Using an integer instead is allowed by the documentation, however it does not explain what it does.
    – ImportanceOfBeingErnest
    Nov 12 '18 at 15:33
















3














I'm seeing '1 and 2' as additional labels in my legend for a seaborn scatterplot. They'll disappear when I set the legend to False, but so does the legend I do want in there.
Any idea where this comes from and how to prevent it from appearing?



This sample code generates the image with the issue;



import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

df = pd.DataFrame({'restHR': np.random.randint(40,65, size=(100,)),
'Time': np.random.randint(0,10, size=(100,))})

sns.set()
fig, ax = plt.subplots()

ax = sns.scatterplot(df['Time'], df['restHR'], size=2, alpha=0.3, label="Race",linewidths=0)

plt.legend(frameon=False, bbox_to_anchor=(1,0.5), loc="center left",prop={'size': 8})
plt.subplots_adjust(right=0.75)

plt.show()


enter image description here










share|improve this question






















  • What is the purpose of size=2? Usually you would do size="columnname" to group sizes. Using an integer instead is allowed by the documentation, however it does not explain what it does.
    – ImportanceOfBeingErnest
    Nov 12 '18 at 15:33














3












3








3







I'm seeing '1 and 2' as additional labels in my legend for a seaborn scatterplot. They'll disappear when I set the legend to False, but so does the legend I do want in there.
Any idea where this comes from and how to prevent it from appearing?



This sample code generates the image with the issue;



import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

df = pd.DataFrame({'restHR': np.random.randint(40,65, size=(100,)),
'Time': np.random.randint(0,10, size=(100,))})

sns.set()
fig, ax = plt.subplots()

ax = sns.scatterplot(df['Time'], df['restHR'], size=2, alpha=0.3, label="Race",linewidths=0)

plt.legend(frameon=False, bbox_to_anchor=(1,0.5), loc="center left",prop={'size': 8})
plt.subplots_adjust(right=0.75)

plt.show()


enter image description here










share|improve this question













I'm seeing '1 and 2' as additional labels in my legend for a seaborn scatterplot. They'll disappear when I set the legend to False, but so does the legend I do want in there.
Any idea where this comes from and how to prevent it from appearing?



This sample code generates the image with the issue;



import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

df = pd.DataFrame({'restHR': np.random.randint(40,65, size=(100,)),
'Time': np.random.randint(0,10, size=(100,))})

sns.set()
fig, ax = plt.subplots()

ax = sns.scatterplot(df['Time'], df['restHR'], size=2, alpha=0.3, label="Race",linewidths=0)

plt.legend(frameon=False, bbox_to_anchor=(1,0.5), loc="center left",prop={'size': 8})
plt.subplots_adjust(right=0.75)

plt.show()


enter image description here







python seaborn scatter-plot






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 15:13









Chrisvdberge

5211822




5211822












  • What is the purpose of size=2? Usually you would do size="columnname" to group sizes. Using an integer instead is allowed by the documentation, however it does not explain what it does.
    – ImportanceOfBeingErnest
    Nov 12 '18 at 15:33


















  • What is the purpose of size=2? Usually you would do size="columnname" to group sizes. Using an integer instead is allowed by the documentation, however it does not explain what it does.
    – ImportanceOfBeingErnest
    Nov 12 '18 at 15:33
















What is the purpose of size=2? Usually you would do size="columnname" to group sizes. Using an integer instead is allowed by the documentation, however it does not explain what it does.
– ImportanceOfBeingErnest
Nov 12 '18 at 15:33




What is the purpose of size=2? Usually you would do size="columnname" to group sizes. Using an integer instead is allowed by the documentation, however it does not explain what it does.
– ImportanceOfBeingErnest
Nov 12 '18 at 15:33












1 Answer
1






active

oldest

votes


















1














It's from size=2. The size parameter is used when you want varied size for the points given a grouped variable.



I am not sure why you have it there, but if you want to adjust the size of the symbol, use s=2 instead.






share|improve this answer





















  • excellent, thanks! This was a consequence of me plotting the size based on another variable previously, but now wanting to set it to a fixed size. 's=' does indeed do the trick. Still makes me wonder where exactly the two additional values come from and why it is 2 values? (as opposed to 1 for the additional variable?). Using size=4 gives me 2 values: 3 and 4 for instance.
    – Chrisvdberge
    Nov 12 '18 at 15:25






  • 1




    I am not sure. It seems to me that seaborn is trying to extrapolate/interpolate integer values when used as input for the 'size' parameter. I tried a few things, if you create a column and assign 2 to all values of that column, it would give you the same result. However, when assigning 1 and 4 to the values, seaborn also creates legend symbols for 2 and 3, although no values are present in that column. Working with strings (e.g. 'foo' and 'bar' instead of 1 and 4) didn't give me this problem.
    – Xiaoyu Lu
    Nov 12 '18 at 15:42











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%2f53265038%2fseaborn-scatterplot-addition-legend-items%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














It's from size=2. The size parameter is used when you want varied size for the points given a grouped variable.



I am not sure why you have it there, but if you want to adjust the size of the symbol, use s=2 instead.






share|improve this answer





















  • excellent, thanks! This was a consequence of me plotting the size based on another variable previously, but now wanting to set it to a fixed size. 's=' does indeed do the trick. Still makes me wonder where exactly the two additional values come from and why it is 2 values? (as opposed to 1 for the additional variable?). Using size=4 gives me 2 values: 3 and 4 for instance.
    – Chrisvdberge
    Nov 12 '18 at 15:25






  • 1




    I am not sure. It seems to me that seaborn is trying to extrapolate/interpolate integer values when used as input for the 'size' parameter. I tried a few things, if you create a column and assign 2 to all values of that column, it would give you the same result. However, when assigning 1 and 4 to the values, seaborn also creates legend symbols for 2 and 3, although no values are present in that column. Working with strings (e.g. 'foo' and 'bar' instead of 1 and 4) didn't give me this problem.
    – Xiaoyu Lu
    Nov 12 '18 at 15:42
















1














It's from size=2. The size parameter is used when you want varied size for the points given a grouped variable.



I am not sure why you have it there, but if you want to adjust the size of the symbol, use s=2 instead.






share|improve this answer





















  • excellent, thanks! This was a consequence of me plotting the size based on another variable previously, but now wanting to set it to a fixed size. 's=' does indeed do the trick. Still makes me wonder where exactly the two additional values come from and why it is 2 values? (as opposed to 1 for the additional variable?). Using size=4 gives me 2 values: 3 and 4 for instance.
    – Chrisvdberge
    Nov 12 '18 at 15:25






  • 1




    I am not sure. It seems to me that seaborn is trying to extrapolate/interpolate integer values when used as input for the 'size' parameter. I tried a few things, if you create a column and assign 2 to all values of that column, it would give you the same result. However, when assigning 1 and 4 to the values, seaborn also creates legend symbols for 2 and 3, although no values are present in that column. Working with strings (e.g. 'foo' and 'bar' instead of 1 and 4) didn't give me this problem.
    – Xiaoyu Lu
    Nov 12 '18 at 15:42














1












1








1






It's from size=2. The size parameter is used when you want varied size for the points given a grouped variable.



I am not sure why you have it there, but if you want to adjust the size of the symbol, use s=2 instead.






share|improve this answer












It's from size=2. The size parameter is used when you want varied size for the points given a grouped variable.



I am not sure why you have it there, but if you want to adjust the size of the symbol, use s=2 instead.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 '18 at 15:21









Xiaoyu Lu

385313




385313












  • excellent, thanks! This was a consequence of me plotting the size based on another variable previously, but now wanting to set it to a fixed size. 's=' does indeed do the trick. Still makes me wonder where exactly the two additional values come from and why it is 2 values? (as opposed to 1 for the additional variable?). Using size=4 gives me 2 values: 3 and 4 for instance.
    – Chrisvdberge
    Nov 12 '18 at 15:25






  • 1




    I am not sure. It seems to me that seaborn is trying to extrapolate/interpolate integer values when used as input for the 'size' parameter. I tried a few things, if you create a column and assign 2 to all values of that column, it would give you the same result. However, when assigning 1 and 4 to the values, seaborn also creates legend symbols for 2 and 3, although no values are present in that column. Working with strings (e.g. 'foo' and 'bar' instead of 1 and 4) didn't give me this problem.
    – Xiaoyu Lu
    Nov 12 '18 at 15:42


















  • excellent, thanks! This was a consequence of me plotting the size based on another variable previously, but now wanting to set it to a fixed size. 's=' does indeed do the trick. Still makes me wonder where exactly the two additional values come from and why it is 2 values? (as opposed to 1 for the additional variable?). Using size=4 gives me 2 values: 3 and 4 for instance.
    – Chrisvdberge
    Nov 12 '18 at 15:25






  • 1




    I am not sure. It seems to me that seaborn is trying to extrapolate/interpolate integer values when used as input for the 'size' parameter. I tried a few things, if you create a column and assign 2 to all values of that column, it would give you the same result. However, when assigning 1 and 4 to the values, seaborn also creates legend symbols for 2 and 3, although no values are present in that column. Working with strings (e.g. 'foo' and 'bar' instead of 1 and 4) didn't give me this problem.
    – Xiaoyu Lu
    Nov 12 '18 at 15:42
















excellent, thanks! This was a consequence of me plotting the size based on another variable previously, but now wanting to set it to a fixed size. 's=' does indeed do the trick. Still makes me wonder where exactly the two additional values come from and why it is 2 values? (as opposed to 1 for the additional variable?). Using size=4 gives me 2 values: 3 and 4 for instance.
– Chrisvdberge
Nov 12 '18 at 15:25




excellent, thanks! This was a consequence of me plotting the size based on another variable previously, but now wanting to set it to a fixed size. 's=' does indeed do the trick. Still makes me wonder where exactly the two additional values come from and why it is 2 values? (as opposed to 1 for the additional variable?). Using size=4 gives me 2 values: 3 and 4 for instance.
– Chrisvdberge
Nov 12 '18 at 15:25




1




1




I am not sure. It seems to me that seaborn is trying to extrapolate/interpolate integer values when used as input for the 'size' parameter. I tried a few things, if you create a column and assign 2 to all values of that column, it would give you the same result. However, when assigning 1 and 4 to the values, seaborn also creates legend symbols for 2 and 3, although no values are present in that column. Working with strings (e.g. 'foo' and 'bar' instead of 1 and 4) didn't give me this problem.
– Xiaoyu Lu
Nov 12 '18 at 15:42




I am not sure. It seems to me that seaborn is trying to extrapolate/interpolate integer values when used as input for the 'size' parameter. I tried a few things, if you create a column and assign 2 to all values of that column, it would give you the same result. However, when assigning 1 and 4 to the values, seaborn also creates legend symbols for 2 and 3, although no values are present in that column. Working with strings (e.g. 'foo' and 'bar' instead of 1 and 4) didn't give me this problem.
– Xiaoyu Lu
Nov 12 '18 at 15:42


















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f53265038%2fseaborn-scatterplot-addition-legend-items%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







這個網誌中的熱門文章

Hercules Kyvelos

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud