How to set the y coordinate(s) of the bars bases in gnuplot bar charts?
Is there any way to set the y coordinate(s) of the bars bases in gnuplot bar charts as the bottom
option in matplotlib?
For example, suppose I have the following data:
0.5 0.2 0.3 0.1 0.2 0.1
0.6 0.1 0.2 0.1 0.2 0.0
0.4 0.2 0.1 0.1 0.5 0.3
In matplotlib I can do the following procedure:
import matplotlib.pyplot as plt
import numpy as np
a = np.loadtxt('sample.dat', usecols=[0], dtype=float).tolist()
a1 = np.loadtxt('sample.dat', usecols=[1], dtype=float).tolist()
b = np.loadtxt('sample.dat', usecols=[2], dtype=float).tolist()
b1 = np.loadtxt('sample.dat', usecols=[3], dtype=float).tolist()
c = np.loadtxt('sample.dat', usecols=[4], dtype=float).tolist()
c1 = np.loadtxt('sample.dat', usecols=[5], dtype=float).tolist()
x_pos = np.arange(len(a))
plt.bar(x_pos,a, align='center', color='green');
plt.bar(x_pos,b, align='center', bottom=a, color='red');
plt.bar(x_pos,c, align='center', bottom=np.add(a, b).tolist(), color='orange');
plt.bar(x_pos,a1, align='center', bottom=None, color='black');
plt.bar(x_pos,b1, align='center', bottom=a, color='blue');
plt.bar(x_pos,c1, align='center', bottom=np.add(a, b).tolist(), color='gray');
plt.xticks(np.arange(0, len(a)));
Getting the following graph:
Bar chart
gnuplot
add a comment |Â
Is there any way to set the y coordinate(s) of the bars bases in gnuplot bar charts as the bottom
option in matplotlib?
For example, suppose I have the following data:
0.5 0.2 0.3 0.1 0.2 0.1
0.6 0.1 0.2 0.1 0.2 0.0
0.4 0.2 0.1 0.1 0.5 0.3
In matplotlib I can do the following procedure:
import matplotlib.pyplot as plt
import numpy as np
a = np.loadtxt('sample.dat', usecols=[0], dtype=float).tolist()
a1 = np.loadtxt('sample.dat', usecols=[1], dtype=float).tolist()
b = np.loadtxt('sample.dat', usecols=[2], dtype=float).tolist()
b1 = np.loadtxt('sample.dat', usecols=[3], dtype=float).tolist()
c = np.loadtxt('sample.dat', usecols=[4], dtype=float).tolist()
c1 = np.loadtxt('sample.dat', usecols=[5], dtype=float).tolist()
x_pos = np.arange(len(a))
plt.bar(x_pos,a, align='center', color='green');
plt.bar(x_pos,b, align='center', bottom=a, color='red');
plt.bar(x_pos,c, align='center', bottom=np.add(a, b).tolist(), color='orange');
plt.bar(x_pos,a1, align='center', bottom=None, color='black');
plt.bar(x_pos,b1, align='center', bottom=a, color='blue');
plt.bar(x_pos,c1, align='center', bottom=np.add(a, b).tolist(), color='gray');
plt.xticks(np.arange(0, len(a)));
Getting the following graph:
Bar chart
gnuplot
add a comment |Â
Is there any way to set the y coordinate(s) of the bars bases in gnuplot bar charts as the bottom
option in matplotlib?
For example, suppose I have the following data:
0.5 0.2 0.3 0.1 0.2 0.1
0.6 0.1 0.2 0.1 0.2 0.0
0.4 0.2 0.1 0.1 0.5 0.3
In matplotlib I can do the following procedure:
import matplotlib.pyplot as plt
import numpy as np
a = np.loadtxt('sample.dat', usecols=[0], dtype=float).tolist()
a1 = np.loadtxt('sample.dat', usecols=[1], dtype=float).tolist()
b = np.loadtxt('sample.dat', usecols=[2], dtype=float).tolist()
b1 = np.loadtxt('sample.dat', usecols=[3], dtype=float).tolist()
c = np.loadtxt('sample.dat', usecols=[4], dtype=float).tolist()
c1 = np.loadtxt('sample.dat', usecols=[5], dtype=float).tolist()
x_pos = np.arange(len(a))
plt.bar(x_pos,a, align='center', color='green');
plt.bar(x_pos,b, align='center', bottom=a, color='red');
plt.bar(x_pos,c, align='center', bottom=np.add(a, b).tolist(), color='orange');
plt.bar(x_pos,a1, align='center', bottom=None, color='black');
plt.bar(x_pos,b1, align='center', bottom=a, color='blue');
plt.bar(x_pos,c1, align='center', bottom=np.add(a, b).tolist(), color='gray');
plt.xticks(np.arange(0, len(a)));
Getting the following graph:
Bar chart
gnuplot
Is there any way to set the y coordinate(s) of the bars bases in gnuplot bar charts as the bottom
option in matplotlib?
For example, suppose I have the following data:
0.5 0.2 0.3 0.1 0.2 0.1
0.6 0.1 0.2 0.1 0.2 0.0
0.4 0.2 0.1 0.1 0.5 0.3
In matplotlib I can do the following procedure:
import matplotlib.pyplot as plt
import numpy as np
a = np.loadtxt('sample.dat', usecols=[0], dtype=float).tolist()
a1 = np.loadtxt('sample.dat', usecols=[1], dtype=float).tolist()
b = np.loadtxt('sample.dat', usecols=[2], dtype=float).tolist()
b1 = np.loadtxt('sample.dat', usecols=[3], dtype=float).tolist()
c = np.loadtxt('sample.dat', usecols=[4], dtype=float).tolist()
c1 = np.loadtxt('sample.dat', usecols=[5], dtype=float).tolist()
x_pos = np.arange(len(a))
plt.bar(x_pos,a, align='center', color='green');
plt.bar(x_pos,b, align='center', bottom=a, color='red');
plt.bar(x_pos,c, align='center', bottom=np.add(a, b).tolist(), color='orange');
plt.bar(x_pos,a1, align='center', bottom=None, color='black');
plt.bar(x_pos,b1, align='center', bottom=a, color='blue');
plt.bar(x_pos,c1, align='center', bottom=np.add(a, b).tolist(), color='gray');
plt.xticks(np.arange(0, len(a)));
Getting the following graph:
Bar chart
gnuplot
gnuplot
asked Nov 10 at 22:51
zoh85429
61
61
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
There is a gnuplot plot style that allows you to specify both the top and bottom of each box (and the left and right also). It is
plot FOO using (x):(y):(xlow):(xhigh):(ylow):(yhigh) with boxxy
However there is a much better was of generating stacked histogram plots such as the one you show.
set style data histogram
set style histogram columnstacked
set style fill solid border lc "black"
plot for [col=4:7] FOO using col title sprintf("Col %d",col)
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There is a gnuplot plot style that allows you to specify both the top and bottom of each box (and the left and right also). It is
plot FOO using (x):(y):(xlow):(xhigh):(ylow):(yhigh) with boxxy
However there is a much better was of generating stacked histogram plots such as the one you show.
set style data histogram
set style histogram columnstacked
set style fill solid border lc "black"
plot for [col=4:7] FOO using col title sprintf("Col %d",col)
add a comment |Â
There is a gnuplot plot style that allows you to specify both the top and bottom of each box (and the left and right also). It is
plot FOO using (x):(y):(xlow):(xhigh):(ylow):(yhigh) with boxxy
However there is a much better was of generating stacked histogram plots such as the one you show.
set style data histogram
set style histogram columnstacked
set style fill solid border lc "black"
plot for [col=4:7] FOO using col title sprintf("Col %d",col)
add a comment |Â
There is a gnuplot plot style that allows you to specify both the top and bottom of each box (and the left and right also). It is
plot FOO using (x):(y):(xlow):(xhigh):(ylow):(yhigh) with boxxy
However there is a much better was of generating stacked histogram plots such as the one you show.
set style data histogram
set style histogram columnstacked
set style fill solid border lc "black"
plot for [col=4:7] FOO using col title sprintf("Col %d",col)
There is a gnuplot plot style that allows you to specify both the top and bottom of each box (and the left and right also). It is
plot FOO using (x):(y):(xlow):(xhigh):(ylow):(yhigh) with boxxy
However there is a much better was of generating stacked histogram plots such as the one you show.
set style data histogram
set style histogram columnstacked
set style fill solid border lc "black"
plot for [col=4:7] FOO using col title sprintf("Col %d",col)
answered Nov 11 at 4:29
Ethan Merritt
1,591257
1,591257
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.
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.
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%2f53244201%2fhow-to-set-the-y-coordinates-of-the-bars-bases-in-gnuplot-bar-charts%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