How to insert a vertical line as legend entry for a vertical graph

by Sral   Last Updated October 09, 2019 15:23 PM - source

I have two graphes, one horizontal (y1) and one vertical (y2) line. For a better identification in the legend, I want the vertical graph (y2) also to be represented by a vertical line in the legend. In other words: left to y2 should be a vertical dashed line (rotation of 90°), while the y1 legend entry stays as it is.

Is there any way to customize the appearance of the legend entry symbols like that? Thank you very much for your help!

the handdrawn is how the legend entry should look like (maybe a bit more professional)

axis background/.style={fill=white},
legend entries={y1,y2},
\addplot [color=black, dashdotted]
  table[row sep=crcr]{%
0   3\\
5   3\\
\addplot [color=black, dashed]
  table[row sep=crcr]{%
0   -100\\
2   100\\
Tags : pgfplots legend

Related Questions

Legend entry not showing correct image

Updated June 28, 2015 15:10 PM

Adding a legend next to subfigures of pgfplots

Updated March 21, 2016 08:09 AM

How to only show legend in pgf plot?

Updated August 05, 2015 16:10 PM

Tikz pictures disappears when adding legend

Updated May 11, 2016 08:09 AM