3

This question continuous my another.

See the code:

\documentclass{scrartcl}
\usepackage{tikz}
\usepackage[per-mode = fraction]{siunitx}
\usetikzlibrary{datavisualization.formats.functions}
\begin{document}
  \begin{tikzpicture}
    \datavisualization[scientific axes = {clean,
                                          end labels
                                         },
                       x axis = {label = $\frac{v}{\si{\cubic\m\per\kg}}$},
                       y axis = {label = $\frac{p}{\si{\bar}}$},
                       data/format = function,
                       visualize as smooth line/.list = {isentropic_press,
                                                         isobaric,
                                                         isentropic_decompress
                                                        }
                      ]
    data[set = isentropic_press] {var x : interval[.5 : 2];
                                  func y = 1 / \value x ^ 1.4;
                                 }
    data[set = isobaric] {var x : interval[.5 : 1];
                          func y = 1 / .5 ^ 1.4;
                         }
    data[set = isentropic_decompress] {var x : interval[1 : 2];
                                       func y = 1 / (\value x - .5) ^ 1.4;%-.5: shifts the function by - 0.5 to the right
                                      }
    %accents important points
    info {\draw (visualization cs:x = 2,
                                  y = {(1 / 2 ^ 1.4)}
                ) circle [radius = 1pt]
            node [right,
                  font = \footnotesize
                 ] {1};
         }
    info {\draw (visualization cs:x = .5,
                                  y = {(1 / .5 ^ 1.4)}
                ) circle [radius = 1pt]
            node [above,
                  font = \footnotesize
                 ] {2};
         }
    info {\draw (visualization cs:x = 1,
                                  y = {(1 / .5 ^ 1.4)}
                ) circle [radius = 1pt]
            node [above,
                  font = \footnotesize
                 ] {3};
         }
    info {\draw (visualization cs:x = 2,
                                  y = {(1 / 1.5 ^ 1.4)}
                ) circle [radius = 1pt]
            node [right,
                  font = \footnotesize
                 ] {4};
         };
  \end{tikzpicture}
\end{document}

The info lines (starts with the comment %accents important points) above looks already the same (only coordinates, alignment and text changes). Is there a way to reduce the amount of code when accenting several points?

The \datavisualization ... info[options]{code} ...; command is described on page 766 of the TikZ & PGF manual.

Thank you for your help in advance!

Su-47
  • 2,508
  • 1
    What do you want to achieve? Do you want to put the point label information into the data? You can put it all into one info via a /.list argument, just like you did with the visualize as arguments. Generally, they are two separate steps: Draw the data graph and the annotation. Within \datavisualization, they are separate. If you need to combine them, you would have to turn to pgfplots. – Huang_d Jun 03 '17 at 14:29
  • 1
    '[O]nly coordinates, alignment and text changes': so what doesn't change? I'm not sure what you're trying to do. – cfr Jun 03 '17 at 19:37
  • Hello @Huang_d and cfr! Thank you for your comments. Sorry for my unclear question. Huang_d yes, I wish to reduce the code which accents the important points. Something like put it all into one info, like you wrote, goes in the right direction. But I have difficulties to achieve it. I don't know how to do it via /.list. Shame on me! Can you please create an answer with the solution you described (put it all into one info via a /.list)? @cfr you are right, the most important things changes. I thought one can reduce the code, because it is already the same. – Su-47 Jun 04 '17 at 11:10

1 Answers1

2

There is not that much to shorten. You can put it all into one info group, as in

\begin{tikzpicture}[change/.style={font=\footnotesize}]
[…]
info {\draw     (visualization cs: x = 2, y= {(1/2^1.4)}) circle [radius = 1pt] node [right, change] {1}
                (visualization cs: x = .5, y= {(1/.5^1.4)}) circle [radius = 1pt] node[above, change] {2}
                (visualization cs: x = 1, y= {(1/.5^1.4)}) circle [radius = 1pt] node[above, change] {3}
                (visualization cs: x = 2, y= {(1/1.5^1.4)}) circle [radius = 1pt] node[right, change] {4}
    ;};
\end{tikzpicture}

I did not manage to put it into a list; But then again, it is only four points. You can alternatively label the nodes as node(A){} and reference them outside of the \datavisualization environment for slightly more control over what is is doing. As far as I know, there is no "put something on the first/last data point" within \datavisualization, which is disappointing. Until that is implemented, you will have to manually address points of interest. After all, tikz does not know which points are special.

Huang_d
  • 1,797