Skip to content

Conversation

@PaulWessel
Copy link
Member

Currently, -Zfile is a plot (and plot3d) option used to assign colours to line segments or polygons via a CPT(z) lookup using the last column in file. The number of lines in file must match the number of lines or polygons. This PR adds two new modifiers to -Z:

+t Instead of modifying the colour, interpret the z-value as transparency in 0-100% range.
+T Expect the two last columns in file to have transparency and z-value and change these on a per-segment basis.

This PR follows from the discussion on the forum.

Here is a simple example of the four ways to draw lines w/wo color and/or with/without transparency:

#!/bin/bash
cat << EOF > z.txt
# [transparency] z-value
35	2
85	8
EOF
cat << EOF > tr.txt
# transparency
35
85
EOF
cat << EOF > t.txt
> first header
0	1
1	2
> yet another
3	2
4	3
EOF
gmt begin linetransp png
	gmt makecpt -T0/10 -Cjet
	gmt subplot begin 2x2 -Fs8c -R-1/5/-1/5
	# Constant red lines
	gmt plot -W15p,red t.txt -c
	# Colored lines, no transparency
	gmt plot -W15p+z t.txt -C -Zz.txt -c
	# Transparent lines, no color
	gmt plot -W15p+z t.txt -Ztr.txt+t  -c
	# Transparent and colored lines
	gmt plot -W15p+z -Zz.txt+T t.txt -C -c
	gmt subplot end
gmt end show

linetransp

Once finalised I will do the same to plot3d.

Currently, -Zfile is used to assign colors to line segments or polygons via a CPT(z) lookup.  This PR adds two modifiers:
+t Instead of modifying the color, use z-value to change transparency
+T Expcet the two last columns in file to have transparency and z-value and change the color and transparency on a per-segment basis.

This PR follows from the discussion on the forum.
@PaulWessel PaulWessel added documentation Improve documentation enhancement Improving an existing feature labels Aug 28, 2023
@PaulWessel PaulWessel added this to the 6.5.0 milestone Aug 28, 2023
@PaulWessel PaulWessel self-assigned this Aug 28, 2023
@PaulWessel PaulWessel changed the title WIP Allow plot -Z to also control line/polygon transparency Allow plot -Z to also control line/polygon transparency Aug 28, 2023
@PaulWessel PaulWessel merged commit dcda92b into master Aug 28, 2023
@PaulWessel PaulWessel deleted the plot-line-color-transp branch August 28, 2023 16:35
@maxrjones maxrjones added the add-changelog Add PR to the changelog label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog documentation Improve documentation enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants