Plot data

Hi everyone! I am trying to plot some data using the command gmt plot but I’m having some issues.
Original data have a .001 file extension and I processed them (I removed some columns) in order to obtain a .csv file. In the end, I exported as .txt file but when I am running the .bat file there are not data visualized. Also, there isn’t any error or warning message while the script runs, it just does not display data. Can anyone help me? I have tried many ways but none it seems to work. Thank you a lot for you help :slight_smile: !

The script is:

gmt begin file1 png
gmt plot filepath\filename.txt -R-800000/0/-4/0 -JX15c/10c -Baf
gmt end show
pause

The result is an empty graph.

Hi,

It’s very difficult for us to help you when we don’t know anything about the contents of your input file.
Can you share at least a line or two?

Since there are no warnings or errors, I bet that the data is outside your chosen -R.

Hi Andreas, thank you for your answer and sorry for the lack of information I gave you.

These are the first lines of the original data file (a .001 file named obs.data.001) I collected. I need to plot the 4th column (-797099.00000, etc.) on the x -axis and the 5th on the y-axis.

I moved the content of the file in an excel environment and I have converted it in a csv file, keeping just the 4th and the 5th column as shown in the figure below:

In the end I exported it as a .txt file in order to plot it on gmt6. The processed file is shown below:

finishedfile

When I run the script:

gmt begin file1 png
gmt plot filepath\filename.txt -R-800000/0/-4/0 -JX15c/10c -Baf
gmt end show
pause

it displays nothing.

Hoping you can help me :slight_smile: and thanks again!

Okay I found out the problem. As you said, it was wrong the -R range. My aim was to plot two datasets with very different interval and I didn’t remember to change -R. So a last question: is it possible to plot a graph with two y-axis? Thank you very much for your help. I am new in using these tools and I made a very naive mistake.

1 Like

Well done! You found your mistake and fixed it.

A general tip when dealing with files with multiple columns is to first make sure that the correct columns are passed to/used by gmt. Check this with e.g, gmt info <file> too see what gmt sees. And adjust -R as needed.

When I have made plots with different y-axis, (I think) a good way is to use a common -J, but different -R. Then use -BWeSn for the first dataset and -BwEsN for the second.

So, same -J, but different -R and -B.

1 Like

Very easy with the Julia wrapper.

1 Like