charts - Tikz 轴图外列被切断

标签 charts latex tikz

尽管图表足够宽(轴线样式),但以下图表的外部列被切掉了。设置图表的宽度也无济于事。任何想法?增加条形宽度需要设置或放大什么?

\begin{tikzpicture}
    \begin{axis}[
    ybar, 
    bar width=0.6cm,
    tick align=inside,
    major grid style={draw=white},
    enlarge y limits={value=.1,upper},
    ymin=0, ymax=100,
    axis x line*=bottom,
    axis y line*=right,
    hide y axis,axis line style={shorten >=-15pt, shorten <=-15pt},
    symbolic x coords={Total, Women, Men},
    xtick=data,
    nodes near coords={\pgfmathprintnumber[precision=0]{\pgfplotspointmeta} }
    ]
    \addplot [draw=none, fill=blue!30] coordinates {
        (Total,75.4064)
        (Women, 72.7961) 
        (Men,94.4597) };
    \addplot [draw=none,fill=red!30] coordinates {
        (Total,75.4064)
        (Women, 89.7961) 
        (Men,94.4597) };
    \addplot [draw=none, fill=green!30] coordinates {
        (Total,75.4064)
        (Women, 89.7961) 
        (Men,94.4597) };
    \legend{}
    \end{axis}
\end{tikzpicture}

enter image description here

最佳答案

您可以增加宽度并减少条形组之间的空间(enlarge x limits=0.25):

\begin{tikzpicture}
    \begin{axis}[
    ybar, 
    bar width=0.6cm,
    enlarge x limits=0.25,
    width=\textwidth,
    tick align=inside,
    major grid style={draw=black},
    enlarge y limits={value=.1,upper},
    ymin=0, ymax=100,
    axis x line*=bottom,
    axis y line*=right,
    hide y axis,axis line style={shorten >=-15pt, shorten <=-15pt},
    symbolic x coords={Total, Women, Men},
    xtick=data,
    nodes near coords={\pgfmathprintnumber[precision=0]{\pgfplotspointmeta} }
    ]
    \addplot [draw=none, fill=blue!30] coordinates {
        (Total,75.4064)
        (Women, 72.7961) 
        (Men,94.4597) };
    \addplot [draw=none,fill=red!30] coordinates {
        (Total,75.4064)
        (Women, 89.7961) 
        (Men,94.4597) };
    \addplot [draw=none, fill=green!30] coordinates {
        (Total,75.4064)
        (Women, 89.7961) 
        (Men,94.4597) };
    \legend{}
    \end{axis}
\end{tikzpicture}

enter image description here

关于charts - Tikz 轴图外列被切断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45791617/

相关文章:

Python:创建数据分布世界地图的简单方法

latex - 如何诊断 Doxygen 1.8.x : LT@LL@FM@cr 生成的 LaTeX 错误

latex - 在带有边缘节点tikz的箭头(不位于下方/上方)之间插入标签

user-interface - 如何防止 MATLAB GUI 中的 LATEX 标签变得模糊?

latex /Miktex : Undefined citations

latex - Tikz 计时选项综合列表

python - 使用 Python 组合九重尖点 multibrot 和九型人格

java - 使用 Google Chart API 从数据库生成图表

javascript - 在散点图上旋转文本

javascript - 在笛卡尔坐标系中绘制矩形