Horizontal chart bars are cropped
up vote
4
down vote
favorite
I have the following code:
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates {
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
which generates a horizontal bar chart. However, Bar A and Bar G are displayed at only half width. How do I make the bar widths the same?
EDIT:
The following is the output:
tikz-pgf pgfplots bar-chart
add a comment |
up vote
4
down vote
favorite
I have the following code:
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates {
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
which generates a horizontal bar chart. However, Bar A and Bar G are displayed at only half width. How do I make the bar widths the same?
EDIT:
The following is the output:
tikz-pgf pgfplots bar-chart
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I have the following code:
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates {
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
which generates a horizontal bar chart. However, Bar A and Bar G are displayed at only half width. How do I make the bar widths the same?
EDIT:
The following is the output:
tikz-pgf pgfplots bar-chart
I have the following code:
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates {
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
which generates a horizontal bar chart. However, Bar A and Bar G are displayed at only half width. How do I make the bar widths the same?
EDIT:
The following is the output:
tikz-pgf pgfplots bar-chart
tikz-pgf pgfplots bar-chart
edited Nov 19 at 9:45
asked Nov 19 at 9:37
qzx
355111
355111
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
6
down vote
accepted
enlargelimits
option can solve the problem.
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,enlargelimits=0.1,
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates{
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
Alternate way
Another way is to set ymin
and ymax
.
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,
ymin={[normalized]-1}, ymax={[normalized]7},
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates{
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
1
Thanks @nidhin.
– qzx
Nov 19 at 10:44
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
enlargelimits
option can solve the problem.
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,enlargelimits=0.1,
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates{
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
Alternate way
Another way is to set ymin
and ymax
.
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,
ymin={[normalized]-1}, ymax={[normalized]7},
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates{
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
1
Thanks @nidhin.
– qzx
Nov 19 at 10:44
add a comment |
up vote
6
down vote
accepted
enlargelimits
option can solve the problem.
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,enlargelimits=0.1,
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates{
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
Alternate way
Another way is to set ymin
and ymax
.
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,
ymin={[normalized]-1}, ymax={[normalized]7},
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates{
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
1
Thanks @nidhin.
– qzx
Nov 19 at 10:44
add a comment |
up vote
6
down vote
accepted
up vote
6
down vote
accepted
enlargelimits
option can solve the problem.
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,enlargelimits=0.1,
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates{
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
Alternate way
Another way is to set ymin
and ymax
.
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,
ymin={[normalized]-1}, ymax={[normalized]7},
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates{
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
enlargelimits
option can solve the problem.
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,enlargelimits=0.1,
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates{
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
Alternate way
Another way is to set ymin
and ymax
.
documentclass[11pt,twoside,a4paper]{article}
usepackage{pgfplots}
begin{document}
begin{figure}
smallbegin{tikzpicture}
begin{axis}[
xmajorticks=false, xbar, y=-0.4cm, bar width=0.3cm,axis lines=left,
ymin={[normalized]-1}, ymax={[normalized]7},
x axis line style={draw=none},
symbolic y coords={A,B,C,D,E,F,G},
ytick=data, nodes near coords, nodes near coords align={horizontal},
]
addplot coordinates{
(1000,A)
(800,B)
(500,C)
(100,D)
(600,E)
(150,F)
(300,G)
};
end{axis}
end{tikzpicture}
end{figure}
end{document}
edited Nov 19 at 10:46
answered Nov 19 at 10:03
nidhin
1,927922
1,927922
1
Thanks @nidhin.
– qzx
Nov 19 at 10:44
add a comment |
1
Thanks @nidhin.
– qzx
Nov 19 at 10:44
1
1
Thanks @nidhin.
– qzx
Nov 19 at 10:44
Thanks @nidhin.
– qzx
Nov 19 at 10:44
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- 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%2ftex.stackexchange.com%2fquestions%2f460707%2fhorizontal-chart-bars-are-cropped%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