Coming soon - Get a detailed view of why an account is flagged as spam!
view details
5
[pgfplots] Plotting a subset of a 3d table as a 2d plot?
Author Summary
caz- is in pgfplots
Post Body

I'm doing surface plots in latex using pgfplots with a table in an external file. I would like to use a subset of that data for a 2 dimensional plot with the third dimension restricted to one value. I'm wondering if there is an easy way to do this. I tried using

\begin{axis}[
    view{90,0},
            restrict x to domain = 0:0.1,
]
\addplot3[mesh] table[x index=0,y index=1, z index=2] {data.dat};
\end{axis}

but it appears that at least at least two x-values must be contained in the stated x-domain, otherwise nothing is plotted. Of course, if I make the x domain larger, I get a segment of a surface plot (or mesh in this example) rather than just one edge (a 2d line plot). If I use

\begin{axis}[
]
\addplot[] table[x index=1,y index=2] {data.dat};
\end{axis}

there is, of course, nothing to tell it to restrict the column 0 values, and I get multiple lines drawn, when I only want one for a particular value in column 0.

In case it's not clear, my table looks something like:

0 0 1
0 1 2
0 2 3
1 0 1.5
1 1 2.5
1 2 3.5
2 0 2
2 1 3
2 2 4

and I want to be able to plot

0 1
1 2
2 3

by telling pgfplots to restrict the x-value to 0, rather than plotting all nine points.

Thanks in advance.

Author
Account Strength
100%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
23,835
Link Karma
1,147
Comment Karma
22,656
Profile updated: 5 days ago
Posts updated: 1 year ago

Subreddit

Post Details

Location
We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
9 years ago