Seite 1 von 1

Schrift wird kleiner in Grafik

Verfasst: Mo 26. Aug 2019, 12:42
von forenthomas
Hallo,

ich komme irgendwie nicht klar mit der Schriftgröße in Grafiken. Jetzt habe ich mal ein konkretes Beispiel:

Wenn ich in der Grafik eine (oder die?) Fläche füllen lasse, dann wird die Schrift vergrößert. Warum? Und wie kann ich das verhindern? Im Moment hantiere ich dann immer noch pro Grafik mit relativen Schriftgrößen (tiny, scriptsize und so) rum, aber das kann's ja irgendwie nicht sein. Wie geht ihr mir Schriftgrößen in Grafiken um?


\documentclass[a4paper, parskip=half, 11pt]{scrartcl}

\usepackage{tikz}           
\usepackage{pgfplots}        
	\pgfplotsset{compat=1.16}
	\usepgfplotslibrary{fillbetween}

\begin{document}

\begin{center}
\begin{tikzpicture}[scale=0.7]
  \begin{axis}[
      axis lines=middle,
      domain=0:42, 
    ]
  	\addplot[name path = N] {-0.8*\x+38.5} node[pos = 0.18,anchor = south west] { $y = -0.8x + 38.5$};
  	\addplot[name path = A] {0.9*\x+4.5} node[pos = 0.2,anchor = north west] {$y = 0.9x + 4.5$};
  	\addplot[name path = T1,domain=0:20, dotted] {22.5};
  	\addplot[gray!20] fill between [of=N and T1, soft clip={domain=0:20}];
   \end{axis}
\end{tikzpicture}  
\end{center}

\begin{center}
\begin{tikzpicture}[scale=0.7]
  \begin{axis}[
      axis lines=middle,
      domain=0:42, 
    ]
  	\addplot[name path = N] {-0.8*\x+38.5} node[pos = 0.18,anchor = south west] { $y = -0.8x + 38.5$};
  	\addplot[name path = A] {0.9*\x+4.5} node[pos = 0.2,anchor = north west] {$y = 0.9x + 4.5$};
   \end{axis}
\end{tikzpicture}  
\end{center}

\end{document}
Für jeden Erkenntnisgewinn dankbar,
Thomas

Verfasst: Mo 26. Aug 2019, 14:49
von Bartman
Mit der zusätzlichen Angabe der Option transform shape passiert das nicht:
\documentclass[parskip=half]{scrartcl}% Papierformat und Schriftgröße sind die Voreinstellung
\usepackage{pgfplots}% lädt tikz

\pgfplotsset{compat=1.16}
\usepgfplotslibrary{fillbetween}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.7, transform shape]
  \begin{axis}[
      axis lines=middle,
      domain=0:42,
      axis on top
    ]
     \addplot [name path = N] {-0.8*\x+38.5} node[pos = 0.18,anchor = south west] {$y = -0.8x + 38.5$};
     \addplot [name path = A] {0.9*\x+4.5} node[pos = 0.2,anchor = north west] {$y = 0.9x + 4.5$};
     \path [name intersections={of=N and A}];
     \draw [name path = T1, dotted] (current axis.origin|-intersection-1) -- (intersection-1);
     \addplot [gray!20] fill between [of=N and T1];
   \end{axis}
\end{tikzpicture}  
\end{center}

\begin{center}
\begin{tikzpicture}[scale=0.7]
  \begin{axis}[
      axis lines=middle,
      domain=0:42
    ]
     \addplot [name path = N] {-0.8*\x+38.5} node[pos = 0.18,anchor = south west] { $y = -0.8x + 38.5$};
     \addplot [name path = A] {0.9*\x+4.5} node[pos = 0.2,anchor = north west] {$y = 0.9x + 4.5$};
   \end{axis}
\end{tikzpicture}
\end{center}
\end{document}
Man kann den Schnittpunkt auch berechnen lassen, statt ihn von Hand einzugeben.

Verfasst: Mo 26. Aug 2019, 17:24
von forenthomas
Hallo Bartman,

danke!! Und das mit dem Schnittpunkt konnte ich auch mal, man vergisst so viel.

Gruß, Thomas

P.S. Ich habe gerade das Bild der Mischung von Bart Simpson und Batman vor Augen - sehr lustig. :)