Plot cyclic data with color (line, symbols and legend)

I share an script which shows how to plot with the same color symbols and lines from the same year from a dataset as the following. It is not so easy because it is necessary to indicate a gap for the lines and to add a column with the year for the symbols.
See cyclic-data-with-color for some background.

# Daily discharge rate in m^/s for the Mississippi River, 1930-1940.

1930-01-01T 14527
1930-01-02T 14810
1930-01-03T 15065
1930-01-04T 15178
1930-01-05T 15234
1940-12-31T 15178

Full script:

gmt begin Mississippi png
	gmt set GMT_THEME cookbook
	gmt basemap -R0/1/0/50 -JX20c/7c -Bxaf -Byaf+l"10@+3@+ m@+3@+/s" -BWSrt+t"Mississippi river annual discharge" 
	# CPT
	gmt makecpt -Crainbow -T1930/1940/1 -F+c1930 -H > a.cpt
	# Plot line
	gmt plot @mississippi.txt -W0.5p,auto -i0,1+s1e-3 -wy -g0z0.05+n --COLOR_SET=a.cpt

	# Process and plot symbols
	gmt convert @mississippi.txt -i0 > year.txt --FORMAT_DATE_OUT=yyyy --FORMAT_CLOCK_OUT=-
	gmt convert @mississippi.txt -i0,1+s1e-3 > a.txt
	paste a.txt year.txt | gmt plot -Sc0.07c -wy -Ca.cpt

	# Legend
	gmt legend -DjTR+w15c -F+i <<-END
	A a.cpt
	N 6
	V 0 1
	S 0.1i r $rect z=1930 0.25p 0.3i 1930
	S 0.1i r $rect z=1931 0.25p 0.3i 1931
	S 0.1i r $rect z=1932 0.25p 0.3i 1932
	S 0.1i r $rect z=1933 0.25p 0.3i 1933
	S 0.1i r $rect z=1934 0.25p 0.3i 1934
	S 0.1i r $rect z=1935 0.25p 0.3i 1935
	S 0.1i r $rect z=1936 0.25p 0.3i 1936
	S 0.1i r $rect z=1937 0.25p 0.3i 1937
	S 0.1i r $rect z=1938 0.25p 0.3i 1938
	S 0.1i r $rect z=1939 0.25p 0.3i 1939
	S 0.1i r $rect z=1940 0.25p 0.3i 1940
gmt end
rm a.cpt year.txt a.txt