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

Creating a directed acyclic graph for an instrumental variables design

0  Asked on March 15, 2021 by tarjei-w-havneraas

   

Creating CV and accompanied document

0  Asked on March 15, 2021

   

Can one “fold” part of the paragraphs in LyX

3  Asked on March 15, 2021 by chap

   

Add vertical line to a pgfplots histogram

1  Asked on March 15, 2021 by martyn-quick

   

How to embed greek text in the pdf using Textstudio

1  Asked on March 15, 2021 by seralouk

   

elsa-cas class comma before figures

0  Asked on March 15, 2021 by riuska

     

Itemize inside algorithm block Lonely item error

1  Asked on March 14, 2021 by duke-le

     

Parse input into commands in expl3

0  Asked on March 14, 2021 by iago-lito-considering-leaving

   

Suppress introductory page numbers

2  Asked on March 14, 2021 by jamaicanworm

   

Wrong arrangement of Table

2  Asked on March 14, 2021 by walter-nazarenus

   

Ask a Question

Get help from others!

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