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/
199 stars 33 forks source link

wrong legend image if one legend from two graphs #42

Open pgf-tikz-bot opened 12 years ago

pgf-tikz-bot commented 12 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/42/ Author: *anonymous Timestamp: 2012-02-01 17:26:08

I want to make one legend out of two graphs. One graph is a line plot the other graph a bar plot. I have made a minimal example attached to this report. I expect that in the legend the symbol for a bar plot is shown for the bar plot (and not the symbol for a line plot (a blue line)).

pgf-tikz-bot commented 12 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/42/#faed Author: nobody Timestamp: 2012-02-01 17:26:09

https://sourceforge.net/p/pgfplots/bugs/_discuss/thread/be77d574/faed/attachment/legendbug.tex minimal example

pgf-tikz-bot commented 12 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/42/#359b Author: ludewich Timestamp: 2012-02-04 15:44:04

pgf-tikz-bot commented 12 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/42/#d652 Author: ludewich Timestamp: 2012-02-04 15:44:04

Thanks for reporting this bug! Seems as if the option list communicated incorrectly.

A work-around is to use add 'ybar,ybar legned' either to the \addlegendimage or to the labelled plot's list (such that its refstyle is updated).

Seems as if there is some unexpected shift in in effect.. I also added a xshift to create the following work-around:

\begin{tikzpicture}

\begin{semilogyaxis}[axis y line*=left,legend style={cells={anchor=west},legend pos=north east}] \addplot[color=red] coordinates {(1, 1) (2, 200) (3, 3000)}; \addlegendentry{line plot} \addlegendimage{refstyle=barplot,xshift=0.5em,}%<----- \addlegendentry{barplot} \end{semilogyaxis}

\begin{axis}[axis y line*=right,ybar,axis x line=none] \addplot+[ybar,ybar legend] %<------ coordinates{(1, 1) (2, 3) (3, 1)}; \label{barplot} \end{axis}

\end{tikzpicture}

ATTENTION: all but the xshift will be compatible with future versions. The shift should havebeen correct as well.

pgf-tikz-bot commented 12 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/42/#643e Author: nobody Timestamp: 2012-02-05 01:24:41

Thanks a lot for your work-around (and pgfplots in general :)...

pgf-tikz-bot commented 8 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/42/#0439 Author: mo-gul Timestamp: 2015-11-22 17:07:01.320000

the barplot legend image is shown, but the unexpected shift is still there ...