How to color line segments like this?

how to plot like this pic.using GMT6.4.0.The data txt have four columns which are longitude latitude degree and time

This is a type of vector plot with what must be presumed non-regularized (i.e., not on a grid) data.

You gave only four parameters: lon, lat, degree, and time.

Which parameter regulates the length of the vectors? Does “degree” specify the vector direction and the color? More information might help to be able to answer further.

A general question is: Which is better for plotting this kind of data? psxy or grdvector?

Using psxy might take some tricky manipulations, given how color is passed in the -W specification. The +cl modifier may be of some utility. Personally, I’ve never tried it.

Interesting question!

If the degree column is to serve as both azimuth and length and z-value for the color-lookup then you need to use -i0,1,2,2,2 with gmt plot so that you basically replicate the degree column two more times and plot will see lon lat degree degree degree. time is not passed on since you do not seem to need it.

Hello @G1oat,

Welcome to the GMT forum @G1oat :slightly_smiling_face:!

Here are some thoughts on this quite general question. Maybe you can post the code you already have and formulate a more specific question or issue you are facing currently.

The posted plot shows shear wave splitting measurements based on the determination of the splitting parameters, which are the fast polarization direction and the delay time.
These data are often displayed as bars with an orientation according to the fast polarization direction (measured clockwise from the north) and a length according to the delay time. Additionally, color-coding is used for the fast polarization direction. The bars are placed at the location of the recording station or the piercing point at a desired depth.

To display the data with GMT, you can use an oriented rectangle (-Sj or -SJ) as a symbol together with plot. Please note:

  • Follow the expected order of the columns of the input data as given in the documentation (longitude, latitude, quantity_used_for_colorcoding, direction_of_bar, length_of_bar, width_of_bar).
  • Think about using j or J. The latter expects geographic azimuths and distances:
    • Typically, the fast polarization direction is measured clockwise from the north.
    • The values of the delay time have to be scaled before using them for the length of the bars.