# Plotting 2D contours using .txt or .dat file

**URL:** https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068
**Category:** ParaView Support
**Created:** [February 25, 2022, 8:46am UTC](https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068 "2022-02-25T08:46:47Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Anwesha\_Varma](https://discourse.paraview.org/user_avatar/discourse.paraview.org/anwesha_varma/32/7134_2.png) [@Anwesha\_Varma](https://discourse.paraview.org/u/Anwesha_Varma)
#### Post date: [February 25, 2022, 8:46am UTC](https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068/1 "2022-02-25T08:46:47Z")

</div>

I have a sample file having 3 columns named “Distance”, “U\_COMP” and “U\_Exact”. I want to plot a 2D contour plot using this .txt file. Let us consider Distance as “X”, U\_COMP as “Y” and U\_exact as “Z”. Other answers for plotting 2D contours are with help of CSV files but due to loss in precision in CSV files, I cant store my data in CSV files. Therefore I need to know how to use .txt file for plotting 2D contours in Paraview. I am currently using Paraview 5.10.0-RC2  
[Wave erf grid t = 0.003.txt](https://discourse.paraview.org/uploads/short-url/rUkNpiVgIkkfPOfwcOXJf14rSjX.txt) (183.4 KB)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 25, 2022, 10:23am UTC](https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068/2 "2022-02-25T10:23:06Z")

</div>

txt and csv will have the same issue.

---

<div class="post-metadata">

### Author: ![Anwesha\_Varma](https://discourse.paraview.org/user_avatar/discourse.paraview.org/anwesha_varma/32/7134_2.png) [@Anwesha\_Varma](https://discourse.paraview.org/u/Anwesha_Varma)
#### Post date: [February 25, 2022, 10:31am UTC](https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068/3 "2022-02-25T10:31:02Z")

</div>

Isn’t there any way a text file could be used for contour plotting in ParaView?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 25, 2022, 10:33am UTC](https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068/4 "2022-02-25T10:33:27Z")

</div>

Well, VTK XML format can be saved as ASCII text file, but I’m not sure to understand why do you need text file here.

---

<div class="post-metadata">

### Author: ![Anwesha\_Varma](https://discourse.paraview.org/user_avatar/discourse.paraview.org/anwesha_varma/32/7134_2.png) [@Anwesha\_Varma](https://discourse.paraview.org/u/Anwesha_Varma)
#### Post date: [February 25, 2022, 11:21am UTC](https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068/5 "2022-02-25T11:21:27Z")

</div>

All my solution files have been written in .txt format. Moreover, converting every text file to a CSV is a very tedious task. Furthermore, I could see a loss of 1-2 decimal places after converting the text file to a CSV file. It would be very kind to suggest some way to plot .txt files in a contour format.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 25, 2022, 11:22am UTC](https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068/6 "2022-02-25T11:22:27Z")

</div>

> [@Anwesha\_Varma](#):
>
> It would be very kind to suggest some way to plot .txt files in a contour format.

You still do not make much sense, do you want to read or write data with ParaView ?

---

<div class="post-metadata">

### Author: ![Anwesha\_Varma](https://discourse.paraview.org/user_avatar/discourse.paraview.org/anwesha_varma/32/7134_2.png) [@Anwesha\_Varma](https://discourse.paraview.org/u/Anwesha_Varma)
#### Post date: [February 25, 2022, 11:25am UTC](https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068/7 "2022-02-25T11:25:53Z")

</div>

I want to read data from the .txt file and plot 2D contours using that file in Paraview.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 25, 2022, 1:27pm UTC](https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068/8 "2022-02-25T13:27:02Z")

</div>

You file seems to contains only “DISTANCE”, “U\_COMP”,“U\_EXACT”, how do you define contours with that ?

---

<div class="post-metadata">

### Author: ![Anwesha\_Varma](https://discourse.paraview.org/user_avatar/discourse.paraview.org/anwesha_varma/32/7134_2.png) [@Anwesha\_Varma](https://discourse.paraview.org/u/Anwesha_Varma)
#### Post date: [February 25, 2022, 5:49pm UTC](https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068/9 "2022-02-25T17:49:29Z")

</div>

Actually, this is not the exact file that I want to plot. I just want to know the methodology of reading .txt files and plotting contours. Just for an example, we can consider DISTANCE as X, U\_COMP as Y, and U\_Exact as Z. Taking Z as function of X and Y. If there is any other format that needs to be followed while plotting contours, kindly suggest.

---

<div class="post-metadata">

### Author: ![timothee.chabat](https://discourse.paraview.org/user_avatar/discourse.paraview.org/timothee.chabat/32/5729_2.png) [@timothee.chabat](https://discourse.paraview.org/u/timothee.chabat)
#### Post date: [February 28, 2022, 7:39am UTC](https://discourse.paraview.org/t/plotting-2d-contours-using-txt-or-dat-file/9068/10 "2022-02-28T07:39:55Z")

</div>

is your issue similar to these ones ? Please take a look at the proposed answers

> [@2D contour from .csv](https://discourse.paraview.org/t/2d-contour-from-csv/2913/4):
>
> OK. What you are describing is not actually contours but rather the coloring of a flat surface. So the first think you need to do is change how you are using Table To Points to generate a flat surface rather than the raised surface. (You are actually making a 3D surface plot, which is useful in its own right, but not what you are asking for.) To do this, turn on the 2D Points option on the Table To Points filter. The Z Column options will then be ignored and all the points will be placed in the …

> [@2D contour from csv with values at array nodes](https://discourse.paraview.org/t/2d-contour-from-csv-with-values-at-array-nodes/4636/3):
>
> Your data is not correctly formated to be read into paraview. it should be like that: val00 val01 val01 ... val09 val10 val11 ... val98 val99
