Wie erreiche ich, dass bei meiner x-Achse die Monatnamen auf deutsch statt auf englisch ausgegeben werden?

Open in Online-Editor
\documentclass{standalone}
\usepackage{tikz,pgfplots}
\usepackage{pgfplotstable}
\usepgfplotslibrary{dateplot}

\begin{document}

\begin{tikzpicture}
  \begin{semilogyaxis}[
    axis background/.style = {shade,top color=gray,bottom color=white},
    width = \textwidth,
    height = 9cm,
    enlargelimits=false,
    ymin=1E-6, ymax=1E-4,
    ylabel = {y-Achse},
    date coordinates in = x,
    date ZERO = 2014-01-01 00,
    xmax = 2014-12-31 23:59,
    xtick = {2014-01-01, 2014-02-01, 2014-03-01, 2014-04-01, 2014-05-01, 2014-06-01, 2014-07-01, 2014-08-01, 2014-09-01, 2014-10-01, 2014-11-01, 2014-12-01},
    xticklabel={\pgfcalendar{tickcal}{\tick}{\tick}{\pgfcalendarshorthand{m}{.}}},
    xticklabel style = {anchor=north},
    xticklabel style = {xshift=15pt}
    ]

    % Data
    \addplot+[const plot, color=blue, fill, blue, mark=] coordinates {
      (2014-01-01 00:00, 2.06E-06)
      (2014-01-01 00:00, 3.56E-06)
      (2014-01-09 11:53, 6.76E-06)
      (2014-01-09 13:21, 3.56E-06)
      (2014-01-13 09:26, 3.56E-06)
      (2014-01-13 09:55, 2.06E-06)
      (2014-02-14 09:05, 2.90E-06)
      (2014-02-14 09:56, 2.06E-06)
      (2014-03-05 07:32, 3.85E-06)
      (2014-03-05 11:04, 2.06E-06)
      (2014-03-06 15:22, 3.85E-06)
      (2014-03-06 16:52, 2.06E-06)
      (2014-03-07 08:06, 2.10E-06)
      (2014-03-07 11:34, 2.06E-06)
      (2014-03-09 01:50, 3.71E-06)
      (2014-03-21 17:15, 2.06E-06)
      (2014-03-25 15:46, 2.10E-06)
      (2014-03-25 16:43, 2.06E-06)
      (2014-03-31 00:00, 2.17E-06)
      (2014-04-02 09:00, 2.06E-06)
      (2014-04-07 00:00, 2.06E-06)
      (2014-04-09 09:00, 2.06E-06)
      (2014-04-14 06:57, 2.10E-06)
      (2014-04-15 15:06, 2.10E-06)
      (2014-04-16 14:36, 2.10E-06)
      (2014-04-17 17:50, 2.06E-06)
      (2014-04-30 10:50, 3.85E-06)
      (2014-04-30 13:12, 2.06E-06)
      (2014-05-04 06:35, 2.21E-06)
      (2014-05-16 19:45, 2.06E-06)
      (2014-05-23 08:35, 2.10E-06)
      (2014-05-23 08:45, 2.06E-06)
      (2014-06-02 07:09, 2.10E-06)
      (2014-06-05 08:13, 3.85E-06)
      (2014-06-05 11:20, 2.10E-06)
      (2014-06-05 14:50, 2.06E-06)
      (2014-06-26 23:30, 3.85E-06)
      (2014-06-27 01:30, 2.06E-06)
      (2014-07-04 23:02, 2.10E-06)
      (2014-07-04 23:12, 2.06E-06)
      (2014-07-14 07:07, 2.10E-06)
      (2014-07-14 13:46, 2.06E-06)
      (2014-07-25 00:55, 2.10E-06)
      (2014-07-25 02:16, 2.06E-06)
      (2014-07-25 07:58, 2.10E-06)
      (2014-07-25 12:00, 2.06E-06)
      (2014-07-25 12:28, 2.10E-06)
      (2014-07-25 14:10, 2.06E-06)
      (2014-08-11 09:00, 2.06E-06)
      (2014-09-12 11:40, 2.06E-06)
      (2014-09-14 09:39, 3.56E-06)
      (2014-09-16 08:52, 7.82E-05)
      (2014-09-29 09:30, 7.82E-05)
      (2014-09-29 09:39, 2.90E-06)
      (2014-10-01 08:52, 2.90E-06)
      (2014-10-01 10:56, 2.06E-06)
      (2014-10-01 11:07, 3.56E-06)
      (2014-10-01 11:46, 2.06E-06)
      (2014-10-06 10:44, 2.10E-06)
      (2014-10-06 10:50, 2.06E-06)
      (2014-10-09 04:36, 2.17E-06)
      (2014-10-09 19:33, 2.06E-06)
      (2014-10-12 06:42, 2.19E-06)
      (2014-10-15 12:54, 3.90E-06)
      (2014-10-30 12:54, 3.90E-06)
      (2014-10-30 20:40, 2.06E-06)
      (2014-10-30 20:54, 2.19E-06)
      (2014-10-31 07:31, 2.36E-06)
      (2014-10-31 09:57, 2.10E-06)
      (2014-10-31 13:38, 2.06E-06)
      (2014-11-06 11:18, 3.85E-06)
      (2014-11-06 12:23, 2.06E-06)
      (2014-11-13 08:30, 2.06E-06)
      (2014-11-13 14:48, 2.06E-06)
      (2014-11-16 19:34, 3.25E-06)
      (2014-12-08 12:30, 2.06E-06)
      (2014-12-10 15:04, 3.85E-06)
      (2014-12-10 17:45, 2.06E-06)
      (2014-12-18 09:35, 3.56E-06)
      (2014-12-18 10:33, 2.06E-06)
      (2014-12-31 23:59, 2.06E-06)
    };

  \end{semilogyaxis}
\end{tikzpicture}  
\end{document}

gefragt 18 Feb '15, 09:37

dzaic's gravatar image

dzaic
63194853
Akzeptiert-Rate: 42%


Die pgfplots Bibliothek dateplot nutzt dafür wie die TikZ Bibliothek calendar das Paket translator, wenn dieses vor den Bibliotheken geladen wurde. Die Dokumentation zu dem Paket translator findet man am Ende der beamer Dokumentation im Kapitel "Translating Strings".

Die zu ladenden Wörterbücher können als Paketoption angegeben werden. Für das deutsche kann man wie bei babel die Option ngerman verwenden.

Bei der Ausgabe genutzt werden dann diejenigen, auf die \languagepath verweist. Voreingestellt für \languagepath ist \languagename,English, wobei \languagename die aktuell verwendete Sprache ist, die zum Beispiel durch das Paket babel gesetzt werden kann. Bei Verwendung von babel und translator wird also automatisch die aktuelle Sprache für die Monatsnamen verwendet.

Mit babel

Wenn Dein gesamtes Dokument Deutsch ist, ist es das einfachste ngerman als Option beim Laden der Klasse anzugeben und babel und translator zu verwenden.

Open in Online-Editor
\documentclass[ngerman]{standalone}
\usepackage{babel}
\usepackage{translator}% muss vor \usepgfplotslibrary{dateplot} stehen
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{dateplot}

Mit polyglossia und neuer Rechtschreibung

Wird statt babel das Paket polyglossia mit \setmainlanguage[spelling=new, babelshorthands=true]{german} dann ist \languagename gleich german. Für translator ist german aber wie bei babel ein Alias für die alte Rechtschreibung, genauer für das Wörterbuch German1997,German. Bei Angabe von ngerman als Paketoption für translator wird aber nur das Wörterbuch German mit der neuen Rechtschreibung geladen. Ändert man jetzt einfach nur die Paketoption in german, bekommt man zwar die deutschen Übersetzungen, aber für die alte Rechtschreibung. Bei den Monatsnamen macht das zwar keinen Unterschied, aber wenn man german als Alias für das Wörterbuch German definiert, dann wird die neue Rechtschreibung genutzt.

Open in Online-Editor
\documentclass[ngerman]{standalone}
\usepackage{polyglossia} \setmainlanguage[spelling=new, babelshorthands=true]{german}
\usepackage{translator}% muss vor \usepgfplotslibrary{dateplot} stehen
\languagealias{german}{German}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{dateplot}

alt text

Code mit babel:

Open in Online-Editor
\documentclass[ngerman]{standalone}
\usepackage{babel}
\usepackage{translator}% muss vor \usepgfplotslibrary{dateplot} stehen
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{dateplot}

\begin{document}
\begin{tikzpicture}
  \begin{semilogyaxis}[
    axis background/.style = {shade,top color=gray,bottom color=white},
    width = \textwidth,
    height = 9cm,
    enlargelimits=false,
    ymin=1E-6, ymax=1E-4,
    ylabel = {y-Achse},
    date coordinates in = x,
    date ZERO = 2014-01-01 00,
    xmax = 2014-12-31 23:59,
    xtick = {2014-01-01, 2014-02-01, 2014-03-01, 2014-04-01, 2014-05-01, 2014-06-01, 2014-07-01, 2014-08-01, 2014-09-01, 2014-10-01, 2014-11-01, 2014-12-01},
    xticklabel={\pgfcalendar{tickcal}{\tick}{\tick}{\pgfcalendarshorthand{m}{.}}},
    xticklabel style = {anchor=north},
    xticklabel style = {xshift=15pt}
    ]
    % Data
    \addplot+[const plot, color=blue, fill, blue, mark=] coordinates {
      (2014-01-01 00:00, 2.06E-06)
      (2014-01-01 00:00, 3.56E-06)
      (2014-01-09 11:53, 6.76E-06)
      (2014-01-09 13:21, 3.56E-06)
      (2014-01-13 09:26, 3.56E-06)
      (2014-01-13 09:55, 2.06E-06)
      (2014-02-14 09:05, 2.90E-06)
      (2014-02-14 09:56, 2.06E-06)
      (2014-03-05 07:32, 3.85E-06)
      (2014-03-05 11:04, 2.06E-06)
      (2014-03-06 15:22, 3.85E-06)
      (2014-03-06 16:52, 2.06E-06)
      (2014-03-07 08:06, 2.10E-06)
      (2014-03-07 11:34, 2.06E-06)
      (2014-03-09 01:50, 3.71E-06)
      (2014-03-21 17:15, 2.06E-06)
      (2014-03-25 15:46, 2.10E-06)
      (2014-03-25 16:43, 2.06E-06)
      (2014-03-31 00:00, 2.17E-06)
      (2014-04-02 09:00, 2.06E-06)
      (2014-04-07 00:00, 2.06E-06)
      (2014-04-09 09:00, 2.06E-06)
      (2014-04-14 06:57, 2.10E-06)
      (2014-04-15 15:06, 2.10E-06)
      (2014-04-16 14:36, 2.10E-06)
      (2014-04-17 17:50, 2.06E-06)
      (2014-04-30 10:50, 3.85E-06)
      (2014-04-30 13:12, 2.06E-06)
      (2014-05-04 06:35, 2.21E-06)
      (2014-05-16 19:45, 2.06E-06)
      (2014-05-23 08:35, 2.10E-06)
      (2014-05-23 08:45, 2.06E-06)
      (2014-06-02 07:09, 2.10E-06)
      (2014-06-05 08:13, 3.85E-06)
      (2014-06-05 11:20, 2.10E-06)
      (2014-06-05 14:50, 2.06E-06)
      (2014-06-26 23:30, 3.85E-06)
      (2014-06-27 01:30, 2.06E-06)
      (2014-07-04 23:02, 2.10E-06)
      (2014-07-04 23:12, 2.06E-06)
      (2014-07-14 07:07, 2.10E-06)
      (2014-07-14 13:46, 2.06E-06)
      (2014-07-25 00:55, 2.10E-06)
      (2014-07-25 02:16, 2.06E-06)
      (2014-07-25 07:58, 2.10E-06)
      (2014-07-25 12:00, 2.06E-06)
      (2014-07-25 12:28, 2.10E-06)
      (2014-07-25 14:10, 2.06E-06)
      (2014-08-11 09:00, 2.06E-06)
      (2014-09-12 11:40, 2.06E-06)
      (2014-09-14 09:39, 3.56E-06)
      (2014-09-16 08:52, 7.82E-05)
      (2014-09-29 09:30, 7.82E-05)
      (2014-09-29 09:39, 2.90E-06)
      (2014-10-01 08:52, 2.90E-06)
      (2014-10-01 10:56, 2.06E-06)
      (2014-10-01 11:07, 3.56E-06)
      (2014-10-01 11:46, 2.06E-06)
      (2014-10-06 10:44, 2.10E-06)
      (2014-10-06 10:50, 2.06E-06)
      (2014-10-09 04:36, 2.17E-06)
      (2014-10-09 19:33, 2.06E-06)
      (2014-10-12 06:42, 2.19E-06)
      (2014-10-15 12:54, 3.90E-06)
      (2014-10-30 12:54, 3.90E-06)
      (2014-10-30 20:40, 2.06E-06)
      (2014-10-30 20:54, 2.19E-06)
      (2014-10-31 07:31, 2.36E-06)
      (2014-10-31 09:57, 2.10E-06)
      (2014-10-31 13:38, 2.06E-06)
      (2014-11-06 11:18, 3.85E-06)
      (2014-11-06 12:23, 2.06E-06)
      (2014-11-13 08:30, 2.06E-06)
      (2014-11-13 14:48, 2.06E-06)
      (2014-11-16 19:34, 3.25E-06)
      (2014-12-08 12:30, 2.06E-06)
      (2014-12-10 15:04, 3.85E-06)
      (2014-12-10 17:45, 2.06E-06)
      (2014-12-18 09:35, 3.56E-06)
      (2014-12-18 10:33, 2.06E-06)
      (2014-12-31 23:59, 2.06E-06)
    };
  \end{semilogyaxis}
\end{tikzpicture}  
\end{document}
Permanenter link

beantwortet 18 Feb '15, 10:35

esdd's gravatar image

esdd
17.7k254256
Akzeptiert-Rate: 62%

bearbeitet 18 Feb '15, 11:48

In dem Minimalbeispiel funktioniert es, da Du dort mit babel arbeitest. Ich nutze jedoch polyglossia. Hier meine Präembel, mit der es leider nicht funktioniert:

Open in Online-Editor

\documentclass[ngerman]{scrreprt}

\usepackage[utf8]{luainputenc} \usepackage{polyglossia} \setmainlanguage[spelling=new, babelshorthands=true]{german}

\usepackage[ngerman]{translator} \usepackage{pgfplots} \usepackage{pgfplotstable} \pgfplotsset{compat=newest} \usepgfplotslibrary{dateplot}

(18 Feb '15, 11:11) dzaic
1

@dzaic Da als Sprache für polyglossia nicht ngerman, sondern german gewählt wurde, muss natürlich auch bei translate die Option german lauten.

(18 Feb '15, 11:21) saputello

@dzaic Das Paket luainputenc ist ein Notfallpaket, falls man eine Datei verarbeiten muss, die nicht die native UTF8-Codierung von LuaLaTeX verwendet. Für UTF8 codierte Dateien braucht man es fast nie und sollte es auch nicht verwenden. Siehe dazu auch die Anleitung zu luainputenc, die bereits im Abstract davor warnt.

(18 Feb '15, 11:24) saputello

@dzaic: Codeblöcke in Kommentaren bitte vermeiden. Sie verhindern u. a., dass man nachfolgende Kommentare noch editieren kann, und verursachen auch einige weitere seltsame Effekte.

(18 Feb '15, 11:31) saputello

@saputtello luainputenc verwende ich, damit Umlaute in Bookmarks bei der Benutzung von hyperlinks angezeigt werden.

Ferner schreibst Du, dass ich Codeblöcke in Kommentaren vermeiden soll. Das beherzige ich gerne, jedoch weiss ich nicht so genau, wie ich mein Anliegen sonst hätte präzisieren können.

(18 Feb '15, 11:35) dzaic

@dzaic Ich habe meine Antwort für den Fall ergänzt. Füge einfach \languagealias{german}{German} nach dem Laden von translator ein.

(18 Feb '15, 11:51) esdd

@dzaic Du hättest Deine Frage editieren können, um dort das für dich wichtige polyglossia im Beispiel zu ergänzen. Notfalls kann man auch einfach einen Absatz und Inline-Code verwenden. Für Dein hyperref-Problem sei eine neue Frage empfohlen.

(18 Feb '15, 11:53) saputello

@dzaic: luainputenc ist eine Krücke, die nur in wirklichen Notfällen verwenden solltest. Für die bookmarks versuche \usepackage[pdfencoding=auto]{hyperref} (zweimal kompilieren).

(18 Feb '15, 12:06) Ulrike Fischer
Ergebnis 5 von 8 show 3 more comments
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:

×296
×19

gestellte Frage: 18 Feb '15, 09:37

Frage wurde gesehen: 9,050 Mal

zuletzt geändert: 18 Feb '15, 12:06