In this question, it seems like adding an extra \draw to a datavisualization should be relatively straightforward. But I'm baffled:


\datavisualization [scientific axes, visualize as scatter]
data [format=named] {
x={0,...,10}, y={0,...,10}
\draw [dashed] (0,1) -- (1,0);

enter image description here

As one can see in the picture, I definitely don't see any line connecting (1,0) or (0,1) here, but instead one that seems to connect (2,0) and (0,pi) (?).

Now the reference manual is, as we all know, not quite as user-friendly as may be hoped. It took me forever to figure out how to get other markers for this ... and if you remove scientific axes then most of the markers disappear.

Anyway, that's just a rant - is this somehow related to some "absolute" coordinates that are mysteriously cropping up? Why does the other question seem to work fine?

(Note: what I really want is just a grid of lattice points with a Matlab-style labeling, but for some reason that seems to be nontrivial.)

  • Downvoter please explain - if there is an "obvious" fix here I'm all ears and ready to get whatever the badge is for closing your own question ... – kcrisman Jul 15 '17 at 1:52
  • Sorry downvote was an accident. Pressed the wrong button. – Ross Jul 16 '17 at 5:39

Drawing after \datavisualization is done using TikZ units. If you want to draw something into the plot using plot coordinates, it has to be done in info (drawing on top of the plot) orinfo' (drawing below the plot) using the visualization coordinate system.


\datavisualization [scientific axes, visualize as scatter]
data [format=named] {
    x={0,...,10}, y={0,...,10}
% add objects on top of the plot
info {
    % uses TikZ units
    \draw [blue] (0,1) -- (1,0);
    % use visualization coordinates
    \draw [dashed] (visualization cs: x=0,y=1) -- (visualization cs: x=1,y=0);
    % center as visualization coordinates, radius in TikZ units
    \fill [red] (visualization cs: x=3,y=3) circle (0.1);
% add objects below the plot
info' {
    \fill [red] (visualization cs: x=6,y=6) circle (0.1);
% uses TikZ units, visualization coordinates are not available here
\draw [red] (0,0) circle (0.1);

enter image description here

  • Thanks! Can you explain though why the question I refer to in my question somehow doesn't need this "info" thing? I must be missing something obvious. – kcrisman Jul 20 '17 at 1:52
  • 1
    @kcrisman: in the question you refered to, school book axes are used, which are not scaled automatically. So there one unit in the coordinate system equals one TikZ unit, which makes it easy to draw something into the plot. You are using scientific axes, which are scaled automatically, so Tikz units and plot units are not the same and plot units in x and y direction also differ. Therefore info and visualization csmust be used to get a specific plot coordinate. – Mike Jul 20 '17 at 21:50
  • Got it! Wow, that is really somewhat subtle, and maybe not the best API ... thank you! – kcrisman Jul 22 '17 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.