2

I'm making a 3D scatter plot of point data (markers only). I want the marker size dependent on one metadata column in my table, and the marker color dependent on another metadata column - I've managed to do this and it works well, using visualization depends on and scatter/@pre marker code/.append style.

I now want to make the marker type conditional on one of the meta values, such that if the meta value is 0, I have marker type A, and otherwise, I have marker type B. I found how to do this in the pgfplots manual (pg. 111 in version 2015/01/31). This method uses scatter/@pre marker code/.code, which overrides all the normal marker styles. I managed to put the marker size command that I had in scatter/@pre marker code/.append style into this command, so the size is mapped correctly, but it remains to map the color to the colormap the way I had it originally for marker type B.

I guess what I'm looking for is the command to say fill={take from colormap} within the following context:

\def\markopts{fill={take from colormap}}

My whole addplot command looked like this originally (no marker style evaluation):

\addplot3[scatter,mark=cube*,only marks,scatter src=explicit,z buffer=sort,
    visualization depends on=\thisrow{m}\as\wtwo,
    scatter/@pre marker code/.append style={%
        /tikz/mark size=0.01+\wtwo/3000,
    }
]
table[x=x,y=y,z=z,meta=density]{Plots/datafilename.txt}
;

With the version including the marker type selection, I had the following:

\addplot3[scatter,mark=cube*,only marks,scatter src=explicit,z buffer=sort,
    visualization depends on=\thisrow{m}\as\wtwo,
    scatter/@pre marker code/.code={%
        \ifdim\wtwo pt<300pt
            \def\markopts{mark=+,mark size=1pt}%
        \else
            \def\markopts{mark=cube*,mark size=0.01+\wtwo/3000}%
        \fi
        \expandafter\scope\expandafter[\markopts]
    },%
    scatter/@post marker code/.code={%
        \endscope
    },%
]
table[x=x,y=y,z=z,meta=density]{Plots/datafilename.txt}
;

closed as unclear what you're asking by Stefan Pinnow, user36296, Zarko, Mensch, Arun Debray Jun 15 '17 at 21:37

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Hi ope, welcome to the site! Could you turn your code snippet into a complete but minimal example document (starting from \documentclass), including some dummy data, to make it easier to start working on a solution? – Jake Jul 21 '15 at 18:29
  • The standard scatter styles all provide a starred version, i.e. something like scatter/use mapped color*. This key might actually do what you want: it uses \pgfplotscolormapdefinemappedcolor\pgfplotspointmetatransformed in order to make fill=mapped color a valid statement. In addition, it uses scatter/@pre marker code/.append code={} and scatter/@post marker code/.prefix code={} in order to append its functionality to an existing style selection. – Christian Feuersänger Jul 26 '15 at 10:24
  • Did the trick from Christian solve your problem or do you need further assistance. If so, please follow Jake's comment. Thanks. – Stefan Pinnow Feb 18 '17 at 11:27

Browse other questions tagged or ask your own question.