# Tikz node for representing range on one dimensional axis

Consider a specific example of representing the range of a parameter value on one dimensional axis.

Blocks corresponding to specific solutes in a multi-solute solution are stacked on top of one another on what is essentially a one dimensional plot with an x-axis of log concentration. The horizontal boundaries of the block are set by the concentration ranges of the solute. This graphic is used to show the relative and absolute concentrations of the constituents of a solution, as well as composition.

An example of a chart composed of these blocks is shown here

There are three cases for the terminations' of the block:

Case I - well-defined concentration limit, a single argument for the termination is, say c. Solid fill.

Case II - well defined concentration limit with some uncertainty in limits / variability in reported concentration, arguments are c1 (least extreme value) and c2 (most extreme value). Fill is 100% at the least extreme value and decreases linearly to 0% at most extreme value.

Case III - poorly defined concentration limit. Arguments are c1 (least extreme value) and c2 (most extreme value). Termination is 100% of the shape height at the least extreme value and decreases linearly to 0% height at most extreme value. The termination always is eroded from the bottom, upwards - the point is along the top, horizontal edge of the shape.

For simplicity's sake, we don't consider that two of these terminations co-occur.

The challenge is to create a shape (and means to pass all required arguments) which accommodates any permutation of the above cases for the termination of the shape. The shape should be called with additional parameters such as fill color, edge line properties and height.

• One sketch = 1000 words ... can you provide one, what you after? Mar 27 at 19:49
• Grateful for your interest. Please see the image / chart linked to above! Mar 28 at 10:14

I don't know whether it is possible to create a custom node shape that has a fading on one or both sides. So, I think, it may be better to use pics for this:

\documentclass[tikz]{standalone}

\def\solutelength{1}
\def\soluteheight{.5}
\def\solutevariabilityhigh{0}
\def\solutevariabilitylow{0}
\def\solutelabelcolor{black}
\tikzset{
pics/solute/.default={s-s},
pics/solute/.style args={#1-#2}{
code={
\def\stylehigh{#2}
\def\stylelow{#1}
\coordinate (-north) at ({.5*\solutelength},\soluteheight);
\coordinate (-south) at ({.5*\solutelength},0);
\coordinate (-south west) at (0,0);
\coordinate (-south east) at (\solutelength,0);
\coordinate (-north west) at (0,\soluteheight);
\coordinate (-north east) at (\solutelength,\soluteheight);
\coordinate (-south west reduced) at ({0+\solutevariabilitylow},0);
\coordinate (-south east reduced) at ({\solutelength-\solutevariabilityhigh},0);
\coordinate (-north west reduced) at ({0+\solutevariabilitylow},\soluteheight);
\coordinate (-north east reduced) at ({\solutelength-\solutevariabilityhigh},\soluteheight);
\fill (-south west reduced) -- (-south) -- (-north) -- (-north west reduced) -- cycle;
\fill[left color=.!0, right color=.] (-south west) -- (-south west reduced) -- (-north west reduced) -- (-north west) -- cycle;
\else
\fill (-south west reduced) -- (-south) -- (-north) -- (-north west) -- cycle;
\fi
\fill (-south) -- (-south east reduced) -- (-north east reduced) -- (-north) -- cycle;
\fill[left color=., right color=.!0] (-south east reduced) -- (-south east) -- (-north east) -- (-north east reduced) -- cycle;
\else
\fill (-south) -- (-south east reduced) -- (-north east) -- (-north) -- cycle;
\fi
\node[text=\solutelabelcolor] (-label) at ($(-south west) !0.5! (-north east)$) {\tikzpictext\strut};
},
},
solute/length/.code={
\def\solutelength{#1}
},
solute/height/.code={
\def\soluteheight{#1}
},
solute/variability high/.code={
\def\solutevariabilityhigh{#1}
},
solute/variability low/.code={
\def\solutevariabilitylow{#1}
},
solute/label color/.code={
\def\solutelabelcolor{#1}
},
solute/label/.style={
pic text={#1}
},
}

\begin{document}

\begin{tikzpicture}
\draw[-stealth, thick] (0,0) -- (11,0);
\foreach \x in {0,...,10} {
\draw (\x,.1) -- ++(0,-.2);
}

\draw (0,.2) pic[yellow, solute/length=2, solute/label={solute a}] {solute};

\draw (1,.7) pic[orange, solute/length=4, solute/variability high=1, solute/label={solute b}] {solute};

\draw (3,1.2) pic[cyan, solute/length=6, solute/variability low=2, solute/variability high=2, solute/label={solute c}] {solute};

\draw (6,.7) pic[orange, solute/length=4, solute/variability low=1, solute/label={solute d}] {solute={f-s}};

\draw (1,-.7) pic[green, solute/length=4, solute/variability high=1, solute/label={solute e}] {solute={f-f}};

\draw (3,-1.2) pic[red, solute/length=4, solute/variability high=2, solute/variability low=1,  solute/label={solute f}] {solute={s-f}};

\draw (4,-1.7) pic[blue, solute/label color=white, solute/length=7, solute/variability high=1, solute/variability low=2,  solute/label={solute g}] {solute={f-f}};

\end{tikzpicture}

\end{document}


• The most basic command is \draw (0,0) pic {solute};.
• You can add options to the pic such as a color that will for example affect the filling. Additionally, there are some special options:
• The length of the block can be defined by solute/length. The height of the block can be defined by solute/height.
• By using pic {solute={x-x}}, you can define the style of the right or left edge of the block, where x can be either s or f and s stands for slope while f stands for fading.
• The length of the slope or the fading can be defined by solute/variability high and solute/variability low. If these values are zero (or not given), there will be no slope and no fading.
• You can change the color of the label by defining solute/label color`.
• Brilliant! Grateful. The faded termination appears to be 2X a line thickness more thick than the main portion of the object. Is that possible? Mar 28 at 12:09
• It should actually not be thicker, and there should not be any border at all. But there may be a rendering error in the above image or in your PDF viewer. If you compile it and zoom into the PDF, you should not see any bprder or diverging thicknesses. Mar 28 at 12:25
• Thanks. Likely a viewer illusion. Tried to PM you with bounce back twice; any guidance is appreciated. Mar 29 at 11:56
• How did you try to do this? We can meet in the chat, if you like. Mar 29 at 12:10