Why dosn't my pen setting work?

Below is my code to plot some really thin dotted lines on my map:

pen=(width=0.00001, color="175/238/238@50", style=".");
plot!(LL, markersize=0, pen=pen
conn=(continuous=true), close=(bot=true),
fmt=:jpg, dpi=300, show=false, savefig=File_w);

The thing is that it is not working. The line is not thin enough and the color is not the color I’m setting. Does anyone know what I’m missing?

Many thanks!

The thinnest possible line you can draw is called faint and has 0 width. What it looks likes depends on the dots per inch.

1 Like

Many thanks for the reply, Paul.

Interesting to know there is a limit in terms of the thinnest possible line. My dots are very dense, it looks like I won’t be able to plot a proper dotted line. It will look like a regular line instead.

I tried to weaken the line by making it half transparent and it is not working well either. Are there any other approaches I could use?

If you have too many points, plot only a subset of them e.g. one every other 10

Also, transparency works only with pdf and png formats

1 Like

Thanks for the suggestions, Joaquim.

I’m plotting the global EEZ lines. I just tried to pick up one lon lat pair out of every 10 pairs. Unfortunately, the plot is kind of messed up. Data points are connected with data points that should not be connected across the global map.

My data are two-column containing longitude and latitude. They are composed of over 300 segments separated with NaNs. When we pick 1 data point out of every 10, sometimes the NaNs are removed causing problems. I can certainly write a loop to fix that, but the issue of this kind of data is that their data density is not consistent. In less dense areas, picking up 1 out of 10 will significantly alter the shape of the geographic area.

Well, I mention the decimation because you said you had many points.
EEZ polygons should not have many points. What for?. I can plot a dotted map quite quickly with an old EEZ file I found in my computer with

EEZ = gmtread("C:/C_e_D/EEZ/World_EEZ.shp");
imshow(EEZ, proj=:guess, ls=".")

1 Like

Maybe gmtsimplify will help? Dont know how this works with NaN’s.

1 Like

Many thanks! It’s wonderful to know that this can be done this way!

I did not know that we could directly plot info out of a shp file. I had to extract the lon lat out of the shp file myself. :grinning: Maybe that was the problem.

So the best way to plot the shp polygons are using imshow? I got the below error:

LoadError: UndefVarError: imshow! not defined
 [1] top-level scope

Here is my code:
EEZ = gmtread("/Volumes/Path1/EEZ_Land.shp");
imshow!(EEZ, ls=".", fmt=:jpg, dpi=600, show=false, savefig=File_w);

Why don’t you do like I showed?

You get that error because imshow! does not exist. imshow is a convenience function to show the result by default (normally one-liners commands). The ! Julia convention is to append to an existing image but you have none to append to. In the more rare occasions where we don’t want to display the image, we use the show=false option.

1 Like

My goal is to plot the EEZ boundaries on my existing map. Therefore, I do need to append it to an existing image.

So, use plot!, not imshow (or imshow(..., show=false), but not so clean)

1 Like

Many thanks !

plot! works, but it has the same issue, i.e., I can not change the pen setting. Here is my code:

EEZ = gmtread("/Volumes/path/eez.shp");
plot!(EEZ, pen=(width=0.1, color=:red, style="."),
fmt=:jpg, dpi=300, show=false, savefig=File_w);

No matter how I change the pen setting, the system will use the default setting and I won’t see any changes at all.

Hmm, I was also expecting this to work pen=(width=5, color=:red, style=".") but it’s not. I’ll have to go see the docs if that is promised. But use this form pen=(0.1, :red, ".") to specify the pen.

A trick when we have surprises is to use the option Vd=1 and see the generated GMT command to spot any obvious errors.

1 Like

Working now :+1:

pen=(0.1, :red, ".") is the way to go. I got the color I want and the dotted lines I want :grinning:

Many thanks!

The code that should deal with the first form rightful has comments saying

elseif (isa(val, NamedTuple))		# Make a recursive call. Will screw if used in mix mode
	# This branch is very convoluted and fragile
1 Like