Plotting multiple data columns (windows os)

my data file has 4 columns: 1 column for y and 3 columns for x (one column for each track).

this is my script:
gmt begin 1 png
gmt basemap -JX10c -R-20/20/0/40 -Bxa5f0.50g0+l"Bias (C)" -Bya5f1g0+l"Altitude (km)"
gmt plot t.csv -W1,red -i0,3
gmt plot t.csv -W1,blue -i1,3
gmt plot t.csv -W1,yellow -i2,3
gmt end show

how to apply this task using single plot line.

Sorry, cannot be done since no information in the file related to z or color. One can have color info in segment headers and instead of all columns together you would instead have 3 x,y segments.

What you have is ok unless you need to make lots of these with different colors.

ok thank you

If you have many columns, you can easily automate this with a list of colours and a for loop.

num_cols=3    #number of columns in the file including y column
color_list=("red" "blue" "yellow")  # this can be RGB codes, list = number of x columns  

for (( i=1; i<= $num_cols; i++ ))


echo "gmt plot t.csv -W1,$color -i$col1,$col2"   # this is to show the output only


With GMT.jl it may well be a one-liner

As a minor tweak to this, get num_cols from the size of the colour list …

1 Like