1

As a followup of this question, i am coping with drawing certain markers. And the solution by John Kormylo works fine for the presented MWE in that question. Here, I would like to extend the plot by two further data items, namely

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{filecontents}{pgfplots-plot-limits.dat}
X    Y    color
0    0    0
0.45    0   1
0.5    0    2
0.55    0    3
\end{filecontents}%
\def\axisdim{6cm}% adjustable size
\begin{document}
    \begin{tikzpicture}
      \clip (0,0) rectangle (\axisdim,\axisdim);
      \pgfdeclareplotmark{thiscube}{\draw[ultra thin, fill] (rel axis cs: 0.23438,-0.5) -- (rel axis cs: 0.26562,-0.5) --
        (rel axis cs:-0.23438,0.5) -- (rel axis cs: -0.26562,0.5);}
      \begin{axis}[colormap/hot,width=\axisdim,height=\axisdim,scale only axis=true,
            xmin=-0.5, xmax=0.5, ymin=-0.5, ymax=0.5,
            axis equal,xtick=\empty, ytick=\empty,hide axis
        ]
        \addplot+[scatter,scatter src=explicit,mark=thiscube,only marks]
            table [x=X,y=Y,meta=color] {pgfplots-plot-limits.dat};
        \pgfplotsextra{\draw[thick,blue] (axis cs:-0.5,-0.5) rectangle (axis cs:0.5,0.5);}
        \end{axis}
    \end{tikzpicture}
\end{document}

Resulting in the following image fourthTry

Which looks as a good solution, the markers are of right size, the first one is in the center (x=0) the right two ones are X=0.45 and X=0.5. However, above the last one, another one (with same distance to the second last) should be present, namely the X=0.55 one. It is not drawn because its origin lies outside the range specifiex by xmin,xmax,ymin,ymax though the marker reaches into the range.

Enlarging the range would (sadly) increase the relatively defined markers, which i don't want to (whether the clip would still work, i haven't checked).

Is there a way to disable this restriction, such that pgfplots would draw markers outside of the specified range? Or is there another solution to get the last data point to be drawn? That would be nice.

Ronny
  • 6,110
  • Just add [clip=false] – John Kormylo Mar 16 '16 at 12:50
  • Thanks for your idea, I haven't had that one this morning, though it is quite simple. Though it does work for the example above, it would not for 0.6 0 3 (which is strange I think). I would like to see all markers that interleave with the given rectangle to be shown. – Ronny Mar 16 '16 at 13:27
  • Are you sure? Did you delete the old pgfplots-plot-limits.dat before trying a new one? (It worked for me.) – John Kormylo Mar 16 '16 at 21:30
  • Oh, on my home computer it works, maybe I was too fast on the laptop and forgot to delete that file. I found another solution yesterday, which is not so nice as setting clipping to false, but i'll document it here today. Can you turn your comment into an (a little longer) answer? I would accept that as the correct one :) – Ronny Mar 17 '16 at 05:45

1 Answers1

1

A solution that does work is to extend the axis limits (by prior knowledge I know that my markers will not exceed the unit cube of the original boundaries, so the complete [-1,1]^2 should suffice. The crop needs to be adapted. And due to the (unwanted) scaling of the marker by extending the limits (its defined relative to the unit cube in the solution above), we define it by basic pgf-commands (which were the first idea of John Kormylo anyway). Then the MWE reads and

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{filecontents}{pgfplots-plot-limits.dat}
X    Y    color
0    0    0
0.45    0   1
0.5    0    2
0.55    0    3
\end{filecontents}%
\def\axisdim{6cm}% adjustable size
\begin{document}
    \begin{tikzpicture}
        \pgfdeclareplotmark{thiscube}{
          \pgfpathmoveto{\pgfpointdiff{\pgfpointxy{0.23438}{-0.5}}{\pgfpointxy{0}{0}}}
          \pgfpathlineto{\pgfpointdiff{\pgfpointxy{0.26562}{-0.5}}{\pgfpointxy{0}{0}}}
          \pgfpathlineto{\pgfpointdiff{\pgfpointxy{-0.23438}{0.5}}{\pgfpointxy{0}{0}}}
          \pgfpathlineto{\pgfpointdiff{\pgfpointxy{-0.26562}{0.5}}{\pgfpointxy{0}{0}}}
          \pgfpathclose
          \pgfusepath{fill}
        }
      \clip (.5*\axisdim,.5*\axisdim) rectangle (1.5*\axisdim,1.5*\axisdim);
      \begin{axis}[colormap/hot,width=2*\axisdim,height=2*\axisdim,scale only axis=true,
            xmin=-1, xmax=1, ymin=-1, ymax=1,
            axis equal,xtick=\empty, ytick=\empty,hide axis
        ]
        \addplot+[scatter,scatter src=explicit,mark=thiscube,only marks]
            table [x=X,y=Y,meta=color] {pgfplots-plot-limits.dat};
        \pgfplotsextra{\draw[thick,blue] (axis cs:-0.5,-0.5) rectangle (axis cs:0.5,0.5);}
        \end{axis}
    \end{tikzpicture}
\end{document}

Though this does work, there is the simpler solution of disabling the clipping, but maybe this approach might be helpful for someone.

Ronny
  • 6,110