TransWikia.com

How to select a range of data within a .csv file in latex using pgfplots?

TeX - LaTeX Asked on September 1, 2021

I am generating a plot of data using pgfplots in latex. I am using data from several excel files as .csv. Here is the MWE:

documentclass[border=5mm,convert]{standalone}
usepackage{pgfplots}
usepackage{siunitx}
usepgfplotslibrary{fillbetween}
begin{document}


begin{tikzpicture}
begin{axis}[
%width=0.9textwidth,
%height=6cm,
%title=This is my graph,
xlabel={Crosshead Extension $Delta$ (si{millimeter})},
ylabel={Load $F$ (si{newton})},
xmin=0.0,
ymin=0,
%grid=major,
]

 addplot+ [smooth,mark=none,name path=boundary1] table [x=CH, y=L, col sep=comma] {ASTMe8Data/SpecimenS6.csv};
 addplot+ [smooth,mark=none,name path=boundary2,] table [x=CH, y=L, col sep=comma] {ASTMe8Data/SpecimenS5.csv};
 addplot+ [smooth,mark=none,name path=boundary3,] table [x=CH, y=L, col sep=comma] {ASTMe8Data/SpecimenS4.csv};
 addplot+ [smooth,mark=none,name path=boundary4,] table [x=CH, y=L, col sep=comma] {ASTMe8Data/SpecimenS3.csv};
 addplot+ [smooth,mark=none,name path=boundary5,] table [x=CH, y=L, col sep=comma] {ASTMe8Data/SpecimenS2.csv};
 addplot+ [smooth,mark=none,name path=boundary6,] table [x=CH, y=L, col sep=comma] {ASTMe8Data/SpecimenS1.csv};

addplot [color=gray!35] fill between [of=boundary1 and boundary2];
addplot [color=gray!35] fill between [of=boundary1 and boundary3];
addplot [color=gray!35] fill between [of=boundary1 and boundary4];
addplot [color=gray!35] fill between [of=boundary1 and boundary5];
addplot [color=gray!35] fill between [of=boundary1 and boundary6];
addplot [color=gray!35] fill between [of=boundary2 and boundary3];
addplot [color=gray!35] fill between [of=boundary2 and boundary4];
addplot [color=gray!35] fill between [of=boundary2 and boundary5];
addplot [color=gray!35] fill between [of=boundary2 and boundary6];
addplot [color=gray!35] fill between [of=boundary3 and boundary4];
addplot [color=gray!35] fill between [of=boundary3 and boundary5];
addplot [color=gray!35] fill between [of=boundary3 and boundary6];
addplot [color=gray!35] fill between [of=boundary4 and boundary5];
addplot [color=gray!35] fill between [of=boundary4 and boundary6];
addplot [color=gray!35] fill between [of=boundary5 and boundary6];

end{axis}
end{tikzpicture}

end{document}

As seen in the MWE, I am calling out six .csv files and using the CS column as my horizontal axis and L column as Y axis. This data is from a tensile steel strength test. These graphs are of crosshead distance vs. Force applied to the steel material as time elapses.

MiKTeX ran out of memory because each file has about 500 rows of data in each column. I am trying to develop an envelope of the six data curves. The problem is related to the fact that I have too many data rows in my .csv excel file. Is there any way to tell pgfplots to only select a certain range of data from the .csv file? Say rows 30-200 in excel? My hope is to cut off some of the initial data and final data because these “book end” data ranges don’t do much for the graph. Any help would be greatly appreciated.

One Answer

I'd filter only the data required for the plot outside LaTeX, e.g. creating new sheets in the spreadsheet with just that data (link to the original cells, just in case) and export those to CSV.

Answered by vonbrand on September 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP