# Why dosn't my pen setting work?

**URL:** <https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325>\
**Category:** GMT.jl Q&A\
**Tags:** gmt\
**Created:** [November 19, 2021, 2:18am UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325 "2021-11-19T02:18:22Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![leon6j](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@leon6j](https://forum.generic-mapping-tools.org/u/leon6j)\
**Post date:** [November 19, 2021, 2:18am UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/1 "2021-11-19T02:18:22Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [November 19, 2021, 4:17am UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/2 "2021-11-19T04:17:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![leon6j](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@leon6j](https://forum.generic-mapping-tools.org/u/leon6j)\
**Post date:** [November 19, 2021, 10:31am UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/3 "2021-11-19T10:31:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 19, 2021, 12:48pm UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/4 "2021-11-19T12:48:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![leon6j](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@leon6j](https://forum.generic-mapping-tools.org/u/leon6j)\
**Post date:** [November 19, 2021, 2:04pm UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/5 "2021-11-19T14:04:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 19, 2021, 4:55pm UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/6 "2021-11-19T16:55:04Z")

</div>

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

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

```

 ![GMTjl_tmp-fs8](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/a/a7a8c5375385335d758002ba482311af4761d551.png)

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [November 19, 2021, 6:14pm UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/7 "2021-11-19T18:14:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![leon6j](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@leon6j](https://forum.generic-mapping-tools.org/u/leon6j)\
**Post date:** [November 19, 2021, 8:37pm UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/8 "2021-11-19T20:37:44Z")

</div>

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. 😀 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
Stacktrace:
 [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);

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 20, 2021, 1:18am UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/9 "2021-11-20T01:18:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![leon6j](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@leon6j](https://forum.generic-mapping-tools.org/u/leon6j)\
**Post date:** [November 20, 2021, 2:24am UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/10 "2021-11-20T02:24:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 20, 2021, 2:25am UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/11 "2021-11-20T02:25:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![leon6j](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@leon6j](https://forum.generic-mapping-tools.org/u/leon6j)\
**Post date:** [November 20, 2021, 9:58am UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/12 "2021-11-20T09:58:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 20, 2021, 1:57pm UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/13 "2021-11-20T13:57:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![leon6j](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@leon6j](https://forum.generic-mapping-tools.org/u/leon6j)\
**Post date:** [November 20, 2021, 2:19pm UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/14 "2021-11-20T14:19:13Z")

</div>

Working now 👍

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

Many thanks!

> [@Joaquim](#):
>
> pen=(0.1, :red, “.”)

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 20, 2021, 2:25pm UTC](https://forum.generic-mapping-tools.org/t/why-dosnt-my-pen-setting-work/2325/15 "2021-11-20T14:25:51Z")

</div>

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

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

```
