pgf-tikz / pgfplots

pgfplots - A TeX package to draw normal and/or logarithmic plots directly in TeX in two and three dimensions with a user-friendly interface and pgfplotstable - a TeX package to round and format numerical tables. Examples in manuals and/or on web site.
http://pgfplots.sourceforge.net/
200 stars 35 forks source link

[bar-chart] bars dissapear when values are >xmax/ymax #163

Closed pgf-tikz-bot closed 4 years ago

pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/163/ Author: mo-gul Timestamp: 2017-03-24 14:13:33.528000

This is a bug report which just repeats what has been stated at http://tex.stackexchange.com/questions/360201.

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{
        compat=1.14,    % <-- changing this value doens't change anything
    }
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            xbar,
            xmax=10,
        ]
            \addplot coordinates {(1,1) (11,2)};
        \end{axis}
    \end{tikzpicture}
    \begin{tikzpicture}
        \begin{axis}[
            ybar,
            ymax=10,
        ]
            \addplot coordinates {(1,1) (2,11)};
        \end{axis}
    \end{tikzpicture}
\end{document}
pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/163/#f2e6 Author: cfeuersaenger Timestamp: 2017-04-28 15:42:54.968000

pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/163/#3b0b Author: cfeuersaenger Timestamp: 2017-04-28 15:42:55.163000

I found the root cause:

The problem is a feature which is useful for "normal plots": if a data point falls outside the prescribed data limits, none of its components contributes to the axis limits. Consequently, the data points in question are there, but their result is invisible since pgfplots has reduced the visible range.

Workarounds are

Unfortunately, 'clip limits=true' still has its uses for bar plots: suppose that you have an 'xbar' plot and its y coordinate falls outside of the visible limit! In this case, you not want to adopt the x limits as well. This distinction is not currently covered by pgfplots, but it sounds as if it is the correct solution.

pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/163/#d02c Author: cfeuersaenger Timestamp: 2017-04-28 15:47:35.678000

suggested solution:

introduce 'clip x limits', 'clip y limits', 'clip z limits' and predefine these styles in the bar plot handlers.

pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/163/#3539 Author: cfeuersaenger Timestamp: 2017-04-29 14:13:32.303000

pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/163/#6071 Author: cfeuersaenger Timestamp: 2017-04-29 14:13:32.553000

I have fixed it.

Note that the fixed requires \pgfplotsset{compat=1.15} since it might affect valid old documents.

pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/163/#d73b Author: cfeuersaenger Timestamp: 2017-04-29 14:20:03.704000