Seite 1 von 1

pgfplot - xtick labels manipulieren

Verfasst: Mo 20. Jul 2015, 14:56
von Eddie144
Hallo zusammen,

ich habe einen Graphen, bei dem die x-Achse in Einheiten von 1000€ beschriftet wird. Zu diesem Zweck möchte ich hinter jedes xtick label ein "K" für "Kilo" anfügen, um das klar zu machen. Wie würde das im unten stehenden Beispiel funktionieren? Ich weiß, dass das im Beispiel keine Tausender sind, aber die Funktionsweise wäre ja identisch. Im Ergebnis stünde dann an der x-Achse "0.5K, 1K, 1.5K" usw.

Vielen Dank schonmal!
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\pgfplotsset{compat=1.5}

\begin{document}


\begin{tikzpicture}
\begin{axis}[
	axis lines = center,
	xlabel near ticks,
	ylabel near ticks,
	width = \textwidth,
	height = 7cm,	
	cycle list name = linestyles*,
	scaled ticks = false,
]
\addplot  {x^(0.5)};
\end{axis}
\end{tikzpicture}


\end{document}

Verfasst: Mo 20. Jul 2015, 23:47
von esdd
Das geht mit
xticklabel={$\pgfmathprintnumber{\tick}$\,K}
Warum verwendest Du eigentlich compat=1.5? Die derzeit aktuelle Version ist 1.12.
\documentclass[12pt,a4paper]{article} 
\usepackage[utf8]{inputenc} 
\usepackage{pgfplots} 
\pgfplotsset{compat=newest} 
\begin{document} 
\begin{tikzpicture} 
\begin{axis}[ 
    axis lines = center, 
    xlabel near ticks, 
    ylabel near ticks, 
    width = \textwidth, 
    height = 7cm,   
    cycle list name = linestyles*, 
    scaled ticks = false,
    xticklabel={$\pgfmathprintnumber{\tick}$\,K}
] 
\addplot  {x^(0.5)}; 
\end{axis} 
\end{tikzpicture} 
\end{document} 
Gruß
Elke



Bild

Verfasst: Di 21. Jul 2015, 02:47
von Eddie144
Vielen Dank!

Ich weiß spontan auch nicht wie ich auf 1.5 komme. :)