alt text

Wie kann ich eine colormap z.B. so einstellen, dass 0 = schwarz, 1 = blau, 2 = rot bedeutet, vorzugsweise mit Farbnamen, also etwa red, nicht rgb() usw.

Mit \pgfplotscolormapdefinemappedcolor{#1} greift man scheints auf die colormap zu, aber wie erstelle ich eine colormap zielführend?

Öffne in Overleaf
\documentclass[margin=5mm, tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps}
\pgfplotsset{compat=1.12}

\tikzset{Farbe/.style={/utils/exec={\pgfplotscolormapdefinemappedcolor{#1}},
draw=black, fill=mapped color}
}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
% Geht nicht
%colormap={test}{color(0cm)=(red); color(1cm)=(blue);  color(2cm)=(red);}
% Alles schwarz
colormap={test}{color=(black) color=(red)},
% 
%colormap/hsv,
hide axis,axis equal,
xmin=-2.5, xmax=5,
ymin=-.5, ymax=.5,
]
\draw[Farbe=0, xshift=-2cm] (0,0) rectangle (1,1);
\draw[Farbe=1] (0,0) rectangle (1,1);
\draw[Farbe=2, xshift=2cm] (0,0) rectangle (1,1) node[right]{IST};

\draw[fill=black, xshift=-2cm, yshift=-2cm] (0,0) rectangle (1,1);
\draw[fill=blue, yshift=-2cm] (0,0) rectangle (1,1);
\draw[fill=red, xshift=2cm, yshift=-2cm] (0,0) rectangle (1,1) node[right]{SOLL};
\end{axis}
\end{tikzpicture}

\end{document}

gefragt 01 Sep '18, 14:28

cis's gravatar image

cis
9.5k75452491
Akzeptiert-Rate: 29%

bearbeitet 01 Sep '18, 14:31


Hab es rausgefunden. Es geht mit

Öffne in Overleaf
% https://tex.stackexchange.com/questions/233600/construct-colormap-for-iso-level-surface-in-pgfplots
\pgfplotsset
{
    colormap={test}%
    {
        [1pt] % colormap steps: 1pt
        color(0pt)=(black);
        color(1pt)=(blue);
        color(2pt)=(red);
        color(3pt)=(orange);
    }
}

und dann

Öffne in Overleaf
index of colormap={<0,1,2,3> of test}

MWE:

alt text

Öffne in Overleaf
\documentclass[margin=5mm, tikz]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps}
\pgfplotsset{compat=1.12}

\begin{document}

% https://tex.stackexchange.com/questions/233600/construct-colormap-for-iso-level-surface-in-pgfplots
\pgfplotsset
{
    colormap={test}%
    {
        [1pt] % colormap steps: 1pt
        color(0pt)=(black);
        color(1pt)=(blue);
        color(2pt)=(red);
        color(3pt)=(orange);
    }
}

\tikzset{farbe/.style={
index of colormap={#1 of test}, fill,
draw=black}
}

\begin{tikzpicture}
\begin{axis}[
hide axis,axis equal, 
xmin=-3.5, xmax=8,
ymin=-.5, ymax=.5,
]
\fill[index of colormap={0 of test}, xshift=-2cm] (0,0) rectangle (1,1);
\draw[farbe=1] (0,0) rectangle (1,1);
\draw[farbe=2, xshift=2cm] (0,0) rectangle (1,1) node[right]{IST};
\draw[farbe=3, xshift=4cm] (0,0) rectangle (1,1);

\draw[fill=black, xshift=-2cm, yshift=-2cm] (0,0) rectangle (1,1);
\draw[fill=blue, yshift=-2cm] (0,0) rectangle (1,1);
\draw[fill=red, xshift=2cm, yshift=-2cm] (0,0) rectangle (1,1) node[right]{SOLL};
\end{axis}
\end{tikzpicture}

\end{document}
Permanenter link

beantwortet 02 Sep '18, 12:35

cis's gravatar image

cis
9.5k75452491
Akzeptiert-Rate: 29%

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
×8

gestellte Frage: 01 Sep '18, 14:28

Frage wurde gesehen: 6,710 Mal

zuletzt geändert: 02 Sep '18, 12:35