Dear All,
I was trying to draw the cross-section profile circles with colors according to depth. So far I use the pygmt.project
command to obtain the cross.out
file
I wanted to use this file (cross.out
) with pygmt.makecpt
command in order to have a CPT palette, until here no problems.
I tried to apply the following command:
fig.plot(data="/home/asus/Documents/Pdoc_res/Catas/cross.dat",
cmap=True, color=df_cross.Depth, projection="X", style="cc",
pen='0.5p,black')
However, I obtained the following error:
GMTInvalidInput: Can't use arrays for color if data is matrix or file.
Does anyone obtained this error?, is it possible to create a color palette for the cross-section depth profile and plot them?, just in case I add my cross.dat
file
Thanks in advance.
cross.dat (6.6 KB)
Tonino
I think PyGMT wants to have all the attributes for a plot in the same data frame or file. It looks like you already read the depth into the df_cross
data array or data frame. Do you have the distance field of the cross.dat
in the same data frame? Then you can use that in the plot command instead instead of the file.
@EJFielding, thank you for the answer, however, I am not sure if you refer this part of the code in which I create teh cross.dat
file and in which I think the first column is the distance
pygmt.project(
data="/home/asus/Documents/Pdoc_res/Catas/Input_GMT_profile_May_To_Sept_2022_POB.csv",
unit=True,
center=[-66.74, -17.57],
endpoint=[-65.52, -17.10],
convention="pz",
width=[-100, 100],
outfile="/home/asus/Documents/Pdoc_res/Catas/cross.dat",
)
fig.basemap(
projection="X10/-6",
region=[-5, 240, -5, 50],
frame=['xafg50+l"Distance"', 'yafg25+l"Depth"', "WSen"],
yshift=-7,
)
Should I change some part of the code to get the distances?,
Thanks in advance.
Tonino
Yes, instead of using pygmt.project
to read in the CSV file and put the output into the outfile “cross.dat”, you can read the CSV file into a dataframe and have the output go into another dataframe that will have the distance and depth values. Or, if you want to keep the outfile, then you can read the “cross.dat” file into a dataframe or array. Either way, you end up with the projected data in a single array or dataframe that you can send to fig.plot
.