Force Python to overlap y axis
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
add a comment |
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
1
I don't understand what you are trying to achieve. Do you want to have a negativehspace
? 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
add a comment |
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
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
python matplotlib subplot
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 negativehspace
? 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
add a comment |
1
I don't understand what you are trying to achieve. Do you want to have a negativehspace
? 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
add a comment |
1 Answer
1
active
oldest
votes
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.
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
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%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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
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%2f53402612%2fforce-python-to-overlap-y-axis%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
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