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 2 days ago
asked 2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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 2 days ago
answered 2 days ago
nidhin
1,530920
1,530920
1
Thanks @nidhin.
– qzx
2 days ago
add a comment |
1
Thanks @nidhin.
– qzx
2 days ago
1
1
Thanks @nidhin.
– qzx
2 days ago
Thanks @nidhin.
– qzx
2 days ago
add a comment |
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