Tikz Legendeneintrag
Verfasst: Di 11. Jun 2024, 10:39
Hallo ich habe in grün etwas ins diagramm eingezeichnet (in diesem fall steigung). Ich möchte jetzt in der Legende einen grünen strich und dann die größe(steig) (bei mir ist es eine gestrichelte Linie und dann die Größe)
Die gestrichelte Linien in meinem diagramm soll bleiben aber nicht in die legende
Die gestrichelte Linien in meinem diagramm soll bleiben aber nicht in die legende
\documentclass[ 11pt, % Schriftgröße paper=a4, DIV=13, % Seitenlayout (Satzspiegel) parskip=half, % Abstand zwischen Absätzen %twoside, % Doppelseitig %openright, % neues Kapitel rechts % cleardoublepage, bibtotoc, % Literaturverzeichis in Inhaltsverzeichnis headsepline, % Kopfzeilentrennlinie headings, % draft, % Korrekturfassung ]{scrreprt} % scrartcl % Eingabecodierung \usepackage[utf8]{inputenc} % Schriftcodierung \usepackage[T1]{fontenc} % Sprachraum \usepackage[ngerman]{babel} % Blindtext \usepackage{blindtext} % Schrifteinstellungen \usepackage{lmodern} % Vektorschrift \renewcommand{\familydefault}{\sfdefault} % Serifenlose Schrift \usepackage{sansmath} % Mathe-Schrift ohne Serifen \sansmath % aktiviert serifenlose Matheschrift \usepackage{microtype} % harmonische Typenverteilung %\usepackage{hyperref} % Literatur einbinden \usepackage{csquotes} % Steuerung der Anführungszeichen \usepackage[ backend=biber, % Sortier-Compiler style=numeric-comp, % Zitationsstil block=ragged, ]{biblatex} \addbibresource{ref/Bibliothek.bib} \usepackage{booktabs} % Mathemodus \usepackage{amsmath,amssymb} % Trennung \hyphenation{Crash-zo-ne} % Bilder einbinden \usepackage{graphicx} \graphicspath{{bilder/}} \usepackage{svg} \usepackage{pgfkeys} \usepackage{tikz} \usetikzlibrary{shapes.geometric, arrows} \tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=red!30] \tikzstyle{io} = [trapezium, trapezium stretches=true, % A later addition trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30] \tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, text width=3cm, draw=black, fill=orange!30] \tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30] \tikzstyle{arrow} = [thick,->,>=stealth] \usepackage{pgfplots}\pgfplotsset{compat=newest} \usetikzlibrary{arrows.meta,positioning,calc} %für lange Tabelle \usepackage{longtable} \usepackage{algorithm} \usepackage{algpseudocode} \usepackage[export]{adjustbox} % für tikz \pgfplotsset{select coords between index/.style 2 args={ x filter/.code={ \ifnum\coordindex<#1\def\pgfmathresult{}\fi \ifnum\coordindex>#2\def\pgfmathresult{}\fi } }} \usepackage{subcaption} \usepackage{pdfpages} \usepackage{acronym}%abkürzung \usetikzlibrary{arrows, decorations.markings} \makeatletter \tikzset{ nomorepostaction/.code=\makeatletter\let\tikz@postactions\pgfutil@empty, my axis/.style={ postaction={ decoration={ markings, mark=at position 1 with { \arrow[ultra thick]{latex} } }, decorate, nomorepostaction }, thin, -, % switch off other arrow tips every path/.append style=my axis % this is necessary %so it works both with "axis lines=left" and "axis lines=center" } } \makeatother \renewcommand*{\chapterheadstartvskip}{\vspace*{-1\baselineskip}}% Abstand einstellen \renewcommand*\chapterheadendvskip{% \vspace*{1\baselineskip plus -1\baselineskip minus .167\baselineskip}} \begin{document} \begin{figure}[htpb] \begin{subfigure}{0.55\textwidth} \begin{tikzpicture} \begin{axis}[ %xtick=\empty, xlabel={$x$}, ylabel={$y$}, ymax=1.1, %title={Plot der Funktion $y = x^2$}, grid=major, domain=0:5, axis line style={my axis}, samples=100, axis lines=left, xticklabel={\ifdim\tick pt=0pt \else\pgfmathprintnumber{\tick}\fi}, legend pos=south east, ] \addplot[red,line width=1.5pt] {1-e^-x}; \addlegendentry{$x$}; % \addplot[blue, dashed]{1}; \addplot[blue,domain=0:1.25,line width=1.5pt]{0.8*x}; \addlegendentry{$y$}; \addplot[gray, dashed,line width=1.5pt]{1}; \end{axis} \end{tikzpicture} \caption{bild a} \label{a} \end{subfigure}% \begin{subfigure}{0.5\textwidth} \begin{tikzpicture} \begin{axis}[ xlabel={$t$}, %ylabel={$xy$}, ymax=1.1, grid=major, domain=0:5, samples=100, axis lines=left, axis line style={my axis}, xticklabel={\ifdim\tick pt=0pt \else\pgfmathprintnumber{\tick}\fi}, legend pos=south east, ] \addplot[red,domain=0:1,line width=1.5pt] {x^2}; \addlegendentry{$x$} \addplot[dashed,domain=0:1,line width=1.5pt] {x}; \draw[green] (0.2,0.2) -- (0.2,0.4) -- (0.4,0.4); \node at (0.2,0.5) [green] {steig}; % Unsichtbarer grüner Plot für die Legende \addlegendimage{green, line width=1.5pt}; \addlegendentry{steig}; \end{axis} \end{tikzpicture} \caption{bild b} \label{b} \end{subfigure} \caption{Veranschaulichung} \end{figure} \end{document}