Force Python to overlap y axis












0















I have 5 subplots that share an x axis with the y axis alternating right and left. What I am hoping to do (but cant seem to figure out) is how to allow the subplots to overlap one another in order to further reduce the space betweenthe plotted data. I am currently manipulating each subplot by calling each axis (example below)



f, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(5, sharex=True, gridspec_kw=  {'hspace':0}, figsize = (9,12))    
ax1.scatter(age_1, dD, facecolor='grey')
...
ax2.plot(data,data)
...


I am unsure if this is even possible using this subplot method, however, I have been unable to remove the bottom and top 'spines' using another method of creating subplots (example below).



plt.figure(sharex=True,figsize=(9,11))
plt.subplot(5,1,1)
plt.scatter(age_1, dD, facecolor='grey')
...


I would love any feedback from someone that has faced this predicament, thanks!










share|improve this question


















  • 1





    I don't understand what you are trying to achieve. Do you want to have a negative hspace? What's the problem with that? Best provide a runnable example code which shows the issue and use it to explain what you want to have differently.

    – ImportanceOfBeingErnest
    Nov 20 '18 at 22:49






  • 1





    Would not it be better to have all the data on the same plot, taking advantage of a secondary Y axis (ax.twinx()) and scaling the data or using a logarithm axis if necessary? I have never seen subplots overlapping each other, but you can probably achieve it by getting the position of the axes and setting a new value. Or maybe use insets?

    – Patol75
    Nov 20 '18 at 22:51
















0















I have 5 subplots that share an x axis with the y axis alternating right and left. What I am hoping to do (but cant seem to figure out) is how to allow the subplots to overlap one another in order to further reduce the space betweenthe plotted data. I am currently manipulating each subplot by calling each axis (example below)



f, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(5, sharex=True, gridspec_kw=  {'hspace':0}, figsize = (9,12))    
ax1.scatter(age_1, dD, facecolor='grey')
...
ax2.plot(data,data)
...


I am unsure if this is even possible using this subplot method, however, I have been unable to remove the bottom and top 'spines' using another method of creating subplots (example below).



plt.figure(sharex=True,figsize=(9,11))
plt.subplot(5,1,1)
plt.scatter(age_1, dD, facecolor='grey')
...


I would love any feedback from someone that has faced this predicament, thanks!










share|improve this question


















  • 1





    I don't understand what you are trying to achieve. Do you want to have a negative hspace? What's the problem with that? Best provide a runnable example code which shows the issue and use it to explain what you want to have differently.

    – ImportanceOfBeingErnest
    Nov 20 '18 at 22:49






  • 1





    Would not it be better to have all the data on the same plot, taking advantage of a secondary Y axis (ax.twinx()) and scaling the data or using a logarithm axis if necessary? I have never seen subplots overlapping each other, but you can probably achieve it by getting the position of the axes and setting a new value. Or maybe use insets?

    – Patol75
    Nov 20 '18 at 22:51














0












0








0








I have 5 subplots that share an x axis with the y axis alternating right and left. What I am hoping to do (but cant seem to figure out) is how to allow the subplots to overlap one another in order to further reduce the space betweenthe plotted data. I am currently manipulating each subplot by calling each axis (example below)



f, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(5, sharex=True, gridspec_kw=  {'hspace':0}, figsize = (9,12))    
ax1.scatter(age_1, dD, facecolor='grey')
...
ax2.plot(data,data)
...


I am unsure if this is even possible using this subplot method, however, I have been unable to remove the bottom and top 'spines' using another method of creating subplots (example below).



plt.figure(sharex=True,figsize=(9,11))
plt.subplot(5,1,1)
plt.scatter(age_1, dD, facecolor='grey')
...


I would love any feedback from someone that has faced this predicament, thanks!










share|improve this question














I have 5 subplots that share an x axis with the y axis alternating right and left. What I am hoping to do (but cant seem to figure out) is how to allow the subplots to overlap one another in order to further reduce the space betweenthe plotted data. I am currently manipulating each subplot by calling each axis (example below)



f, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(5, sharex=True, gridspec_kw=  {'hspace':0}, figsize = (9,12))    
ax1.scatter(age_1, dD, facecolor='grey')
...
ax2.plot(data,data)
...


I am unsure if this is even possible using this subplot method, however, I have been unable to remove the bottom and top 'spines' using another method of creating subplots (example below).



plt.figure(sharex=True,figsize=(9,11))
plt.subplot(5,1,1)
plt.scatter(age_1, dD, facecolor='grey')
...


I would love any feedback from someone that has faced this predicament, thanks!







python matplotlib subplot






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 22:35









otinianootiniano

11




11








  • 1





    I don't understand what you are trying to achieve. Do you want to have a negative hspace? What's the problem with that? Best provide a runnable example code which shows the issue and use it to explain what you want to have differently.

    – ImportanceOfBeingErnest
    Nov 20 '18 at 22:49






  • 1





    Would not it be better to have all the data on the same plot, taking advantage of a secondary Y axis (ax.twinx()) and scaling the data or using a logarithm axis if necessary? I have never seen subplots overlapping each other, but you can probably achieve it by getting the position of the axes and setting a new value. Or maybe use insets?

    – Patol75
    Nov 20 '18 at 22:51














  • 1





    I don't understand what you are trying to achieve. Do you want to have a negative hspace? What's the problem with that? Best provide a runnable example code which shows the issue and use it to explain what you want to have differently.

    – ImportanceOfBeingErnest
    Nov 20 '18 at 22:49






  • 1





    Would not it be better to have all the data on the same plot, taking advantage of a secondary Y axis (ax.twinx()) and scaling the data or using a logarithm axis if necessary? I have never seen subplots overlapping each other, but you can probably achieve it by getting the position of the axes and setting a new value. Or maybe use insets?

    – Patol75
    Nov 20 '18 at 22:51








1




1





I don't understand what you are trying to achieve. Do you want to have a negative hspace? What's the problem with that? Best provide a runnable example code which shows the issue and use it to explain what you want to have differently.

– ImportanceOfBeingErnest
Nov 20 '18 at 22:49





I don't understand what you are trying to achieve. Do you want to have a negative hspace? What's the problem with that? Best provide a runnable example code which shows the issue and use it to explain what you want to have differently.

– ImportanceOfBeingErnest
Nov 20 '18 at 22:49




1




1





Would not it be better to have all the data on the same plot, taking advantage of a secondary Y axis (ax.twinx()) and scaling the data or using a logarithm axis if necessary? I have never seen subplots overlapping each other, but you can probably achieve it by getting the position of the axes and setting a new value. Or maybe use insets?

– Patol75
Nov 20 '18 at 22:51





Would not it be better to have all the data on the same plot, taking advantage of a secondary Y axis (ax.twinx()) and scaling the data or using a logarithm axis if necessary? I have never seen subplots overlapping each other, but you can probably achieve it by getting the position of the axes and setting a new value. Or maybe use insets?

– Patol75
Nov 20 '18 at 22:51












1 Answer
1






active

oldest

votes


















0














It's hard to let these 5 subplots matching the x-axis while remaining as 5 separated subplots.



So as @Patol75 mentioned in the comment, I think another way you may consider is to put them in one single plot since the data share one common axis.



dataSet = [age_1, age_2, age_3, age_4, age_5] # I assume that's the data
colorSet = ['r', 'g', 'b', 'm', 'y'] #or other color
for age, color in zip(dataSet, colorSet):
plt.scatter(age_1, dD, facecolor = color)


If the y-data has too big a magnitude, you could normalize it to gather them together.






share|improve this answer
























  • This is how I originally set up the problem but I wasn't able to find a way to change the subplot coordinates within the larger figure. I have since stumbled onto the ax.set_position command which allowed me to manipulate each subplot's position! Thank you, I appreciate your help!

    – otiniano
    Nov 22 '18 at 5:26











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%2f53402612%2fforce-python-to-overlap-y-axis%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














It's hard to let these 5 subplots matching the x-axis while remaining as 5 separated subplots.



So as @Patol75 mentioned in the comment, I think another way you may consider is to put them in one single plot since the data share one common axis.



dataSet = [age_1, age_2, age_3, age_4, age_5] # I assume that's the data
colorSet = ['r', 'g', 'b', 'm', 'y'] #or other color
for age, color in zip(dataSet, colorSet):
plt.scatter(age_1, dD, facecolor = color)


If the y-data has too big a magnitude, you could normalize it to gather them together.






share|improve this answer
























  • This is how I originally set up the problem but I wasn't able to find a way to change the subplot coordinates within the larger figure. I have since stumbled onto the ax.set_position command which allowed me to manipulate each subplot's position! Thank you, I appreciate your help!

    – otiniano
    Nov 22 '18 at 5:26
















0














It's hard to let these 5 subplots matching the x-axis while remaining as 5 separated subplots.



So as @Patol75 mentioned in the comment, I think another way you may consider is to put them in one single plot since the data share one common axis.



dataSet = [age_1, age_2, age_3, age_4, age_5] # I assume that's the data
colorSet = ['r', 'g', 'b', 'm', 'y'] #or other color
for age, color in zip(dataSet, colorSet):
plt.scatter(age_1, dD, facecolor = color)


If the y-data has too big a magnitude, you could normalize it to gather them together.






share|improve this answer
























  • This is how I originally set up the problem but I wasn't able to find a way to change the subplot coordinates within the larger figure. I have since stumbled onto the ax.set_position command which allowed me to manipulate each subplot's position! Thank you, I appreciate your help!

    – otiniano
    Nov 22 '18 at 5:26














0












0








0







It's hard to let these 5 subplots matching the x-axis while remaining as 5 separated subplots.



So as @Patol75 mentioned in the comment, I think another way you may consider is to put them in one single plot since the data share one common axis.



dataSet = [age_1, age_2, age_3, age_4, age_5] # I assume that's the data
colorSet = ['r', 'g', 'b', 'm', 'y'] #or other color
for age, color in zip(dataSet, colorSet):
plt.scatter(age_1, dD, facecolor = color)


If the y-data has too big a magnitude, you could normalize it to gather them together.






share|improve this answer













It's hard to let these 5 subplots matching the x-axis while remaining as 5 separated subplots.



So as @Patol75 mentioned in the comment, I think another way you may consider is to put them in one single plot since the data share one common axis.



dataSet = [age_1, age_2, age_3, age_4, age_5] # I assume that's the data
colorSet = ['r', 'g', 'b', 'm', 'y'] #or other color
for age, color in zip(dataSet, colorSet):
plt.scatter(age_1, dD, facecolor = color)


If the y-data has too big a magnitude, you could normalize it to gather them together.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '18 at 4:51









Amarth GûlAmarth Gûl

455519




455519













  • This is how I originally set up the problem but I wasn't able to find a way to change the subplot coordinates within the larger figure. I have since stumbled onto the ax.set_position command which allowed me to manipulate each subplot's position! Thank you, I appreciate your help!

    – otiniano
    Nov 22 '18 at 5:26



















  • This is how I originally set up the problem but I wasn't able to find a way to change the subplot coordinates within the larger figure. I have since stumbled onto the ax.set_position command which allowed me to manipulate each subplot's position! Thank you, I appreciate your help!

    – otiniano
    Nov 22 '18 at 5:26

















This is how I originally set up the problem but I wasn't able to find a way to change the subplot coordinates within the larger figure. I have since stumbled onto the ax.set_position command which allowed me to manipulate each subplot's position! Thank you, I appreciate your help!

– otiniano
Nov 22 '18 at 5:26





This is how I originally set up the problem but I wasn't able to find a way to change the subplot coordinates within the larger figure. I have since stumbled onto the ax.set_position command which allowed me to manipulate each subplot's position! Thank you, I appreciate your help!

– otiniano
Nov 22 '18 at 5:26


















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%2f53402612%2fforce-python-to-overlap-y-axis%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

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy