How to disconnect lines in pswiggle

Hello all,

Silly question and new to GMT but I have a list of x, y, and z coordinates to connect points together in a plot. I would like to know how to disconnect or create a gap between a few of the values where there is no line connecting the points. Does anyone know a quick fix for this?


Just insert NaNs where you wan to break the line. e.g.

0 0 10
1 1 11
NaN NaN 0
3 4 13

or make it a multi-segment file

0 0 10
1 1 11
3 4 13
1 Like

You could also try the -g option.

1 Like

Thank you!

The following is an answer generated by ChatGPT to the original question: The first part is ok. The gmt code has -K in excess.

Yes, you can create gaps in a plot between certain points in GMT by using the NaN value. The NaN value stands for “Not a Number” and is used to indicate missing or undefined values. In a GMT plot, any point with a NaN value for the x or y coordinate will not be plotted and will create a gap in the line connecting the points.

Here’s an example of how you can use NaN values to create gaps in your plot:

Copy code

# Create a data file with some x, y, and z values
echo "1 2 3" > data.txt
echo "2 3 4" >> data.txt
echo "3 4 5" >> data.txt
echo "NaN NaN NaN" >> data.txt
echo "4 5 6" >> data.txt
echo "5 6 7" >> data.txt

# Use the psxy command to plot the data, with a gap between the 3rd and 4th point
gmt psxy data.txt -Jx1i -R0/6/0/8 -B -Sc0.1i -Gblack -W1p -K >

# Display the plot
gmt psconvert -A -Tg

In this example, the data file “data.txt” contains 6 points, but between the third and fourth point, the x and y values are set to NaN creating a gap in the line connecting the points.

You can also use NaN values in a .csv file, you just need to use a specific way of writing NaN, for example NaN or nan.

Keep in mind that this is just one way to create gaps in your plot, and depending on the complexity of your data and your specific needs, there may be other ways to achieve the same result.

Finally, much can be achieved via -g.