AnswerBun.com

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

TeX - LaTeX Asked on January 6, 2022

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 January 6, 2022

Add your own answers!

Related Questions

Place the link of the .bib references on a word

0  Asked on February 22, 2021 by alejandro-fernndez-surez

     

Configuring syntax highlighting in Latex

0  Asked on February 22, 2021

 

Drawing a more connected hierarchical diagram

1  Asked on February 22, 2021 by hagbard

   

Text left, figure WITH CAPTION right

1  Asked on February 21, 2021 by susi

   

How to include a .txt file content inside the Latex file

0  Asked on February 21, 2021 by krishna-matsa

 

AwesomeCV projects section remove space in cventry

1  Asked on February 21, 2021 by k-split-x

     

Sidebar next page error in FortySecondsCV LaTeX template

1  Asked on February 21, 2021 by amine-kaabar

   

How to make an empty box

4  Asked on February 21, 2021

 

Print content .unknown pgfkeys

1  Asked on February 21, 2021 by alma

   

Display problems with a tikz-cd diagram

1  Asked on February 21, 2021 by cos_dm_math21

   

Ask a Question

Get help from others!

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