Ich verwende width=3.5cm, height=2.5cm,; beim Audruck messe ich jedoch:

alt text

Woran liegt das?

Open in Online-Editor
\documentclass[paper=a5]{scrartcl}
%\documentclass[border=2pt, varwidth]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}% derzeit aktuelle Version
%\pgfplotsset{compat=newest}% Overleaf hat nur Version 1.11

\usepackage{filecontents}
\begin{filecontents}{data.csv}
5   0   0.59049 0.32768 0.23730 0.16807 0.07776 0.03125
5   1   0.91854 0.73728 0.63281 0.52822 0.33696 0.18750
5   2   0.99144 0.94208 0.89648 0.83692 0.68256 0.50000
5   3   0.99954 0.99328 0.98438 0.96922 0.91296 0.81250
5   4   0.99999 0.99968 0.99902 0.99757 0.98976 0.96875
\end{filecontents}

% Skalierbare Schrift
\usepackage{lmodern}
    \newcommand\mini{\fontsize{2.5pt}{3pt}\selectfont}
       \newcommand\Mini{\fontsize{3.5pt}{3pt}\selectfont}

\usepackage{lipsum}
\begin{document}
% Pfeil aus Technisches Zeichnen
\usetikzlibrary{arrows.meta}
\tikzset{
  >={Triangle[length=0pt 9.0009,width=0pt 3.0003]},
}
\pgfplotsset{
  % override ``-stealth'' for open axes
  every non boxed x axis/.append style={
    x axis line style={->}
  },
  every non boxed y axis/.append style={
    y axis line style={->}
  },
  every non boxed z axis/.append style={
    z axis line style={->}
  }
}
% ==================

\pgfplotsset{mystyle/.style={%
  % allgemein
%  ybar interval,%=10pt, ?  % Balkendiagramm
  /pgf/number format/use comma, % Kommas als Zahlentrennzeichen
  % x und y
  axis lines = middle,% < Achsenstil so früh wie möglich einstellen - er ändert weitere Optionen
  axis line style={->}, %y axis line style={-latex}, 
  ticklabel style = {font=\tiny},
  major tick length =2pt, 
  % x
  xmin=0,
  xmax=5, 
  xtick=data,
%  hide obscured x ticks=false,% <- zum Anzeigen des Ticklabels 0 % TUT NET
  xlabel style={anchor=north, font=\Mini,},
  enlarge x limits={abs=10pt,upper},% <- damit die Pfeilspitze an der y-Achse sichtbar ist
  xticklabel style = {yshift=0.5pt, font=\mini},
  % y
  ymin=0,
  ymax=1,
  ytick = {0.2, 0.4, ..., 1},
  ytickmax=1,% <- kein Tick oberhalb von y=.9
  ylabel style={anchor=north west, yshift=1ex, font=\Mini,},
  enlarge y limits={abs=10pt,upper},
  yticklabel style = {xshift=0.5pt, font=\mini},
}}%

\begin{tikzpicture}[
scale=1.0,
%inner sep=2pt, 
%outer sep=2pt, 
]
\begin{axis}[mystyle, 
  width=3.5cm, height=2.5cm,
  xlabel={$k$},
  ylabel={$P(X \leq k)$},
]
  \addplot[draw=gray, thin,  mark=*, mark size=0.75pt, mark options = {draw=black, fill=white, thin}] table [x index=1, y index=6] {data.csv};
   \addplot[draw=black, ultra thin, densely dashdotted, domain=0:5.5] {1};
  \end{axis} 
\end{tikzpicture}
\end{document}

gefragt 23 Jan '16, 18:20

cis's gravatar image

cis
9.5k78452491
Akzeptiert-Rate: 29%


width und height bezeichnen die Zielgröße der Grafik inklusive aller Labels. Man kann jedoch mit Hilfe von scale only axis einstellen, ob diese Beschränkung für die ganze Grafik oder nur die Achsen gelten soll. Die Anleitung sagt dazu

If scale only axis is enabled, width and height apply only to the axis rectangle. Consequently, the resulting figure is larger than width and height (because of any axis descriptions). However, the axis box has exactly the prescribed target dimensions. If scale only axis=false (the default), pgfplots will try to produce the desired width including labels, titles and ticks.

Für das Beispiel aus der Frage bedeutet dies

Open in Online-Editor
\begin{axis}[
  scale only axis=true,
  width=3.5cm, height=2.5cm,…
Permanenter link

beantwortet 24 Jan '16, 20:32

Henri's gravatar image

Henri
15.7k133943
Akzeptiert-Rate: 46%

bearbeitet 24 Jan '16, 20:33

Deine Antwort
Vorschau umschalten

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Markdown-Grundlagen

  • *kursiv* oder _kursiv_
  • **Fett** oder __Fett__
  • Link:[Text](http://url.com/ "Titel")
  • Bild?![alt Text](/path/img.jpg "Titel")
  • nummerierte Liste: 1. Foo 2. Bar
  • zum Hinzufügen ein Zeilenumbruchs fügen Sie einfach zwei Leerzeichen an die Stelle an der die neue Linie sein soll.
  • grundlegende HTML-Tags werden ebenfalls unterstützt

Frage-Themen:

×728
×296

gestellte Frage: 23 Jan '16, 18:20

Frage wurde gesehen: 13,382 Mal

zuletzt geändert: 24 Jan '16, 20:33