# Legend from a input file

**URL:** <https://forum.generic-mapping-tools.org/t/legend-from-a-input-file/2320>\
**Category:** PyGMT Q&A\
**Created:** [November 18, 2021, 3:16pm UTC](https://forum.generic-mapping-tools.org/t/legend-from-a-input-file/2320 "2021-11-18T15:16:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonino13](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/tonino13/32/1440_2.png) [@tonino13](https://forum.generic-mapping-tools.org/u/tonino13)\
**Post date:** [November 18, 2021, 3:16pm UTC](https://forum.generic-mapping-tools.org/t/legend-from-a-input-file/2320/1 "2021-11-18T15:16:44Z")

</div>

Dear All,  
I am trying to use an input file for the legend on my map (attached).[fault\_legend.dat](https://forum.generic-mapping-tools.org/uploads/short-url/4UNPimquXTlexfa6XCDbqkEPzsi.dat) (237 Bytes)

I did the command:

> ```
> fig.legend(spec=r'D:\Inves\MT\map_data\fault_legend.dat', 
> position="jTR+o0.1c", box=True) 
> 
> ```

However I get the following error:

> GMTCLibError: Module ‘legend’ failed with status code 79:  
> legend [ERROR]: Must specify -D…+w if codes other than D, H, L, S, V are used

Is the error related to input file?, would you mind give me some tips on it.  
Stay safe and best regards,  
Tonino

---

<div class="post-metadata">

**Author:** ![Truyenpt](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@Truyenpt](https://forum.generic-mapping-tools.org/u/Truyenpt)\
**Post date:** [November 20, 2021, 9:20am UTC](https://forum.generic-mapping-tools.org/t/legend-from-a-input-file/2320/2 "2021-11-20T09:20:45Z")

</div>

Hi Tonino:

The error indicated that you must specify -D..+w, so you just add: position=“jTR+o0.1c+w3.5c”  
You can adjust the “+w3.5c” to change the size of the box.

I just tried to plot the legend file and I got the result below:

 ![image](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/8/8e249219802b7290f05b5739e0cf804160fb7e20.png)

PTT

---

<div class="post-metadata">

**Author:** ![tonino13](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/tonino13/32/1440_2.png) [@tonino13](https://forum.generic-mapping-tools.org/u/tonino13)\
**Post date:** [November 22, 2021, 12:10pm UTC](https://forum.generic-mapping-tools.org/t/legend-from-a-input-file/2320/3 "2021-11-22T12:10:40Z")

</div>

@Truyenpt, thank you for the tip,  
stay safe and best regards  
Tonino

---

<div class="post-metadata">

**Author:** ![tonino13](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/tonino13/32/1440_2.png) [@tonino13](https://forum.generic-mapping-tools.org/u/tonino13)\
**Post date:** [November 22, 2021, 2:44pm UTC](https://forum.generic-mapping-tools.org/t/legend-from-a-input-file/2320/4 "2021-11-22T14:44:57Z")

</div>

Dear @Truyenpt,  
Is there a way to specify the color for the lines at the legend box?. I tried with the following line:

> S 0.25c - 0.5c magenta thin 0.7c Mandeyapecua

but it keeps like black line, any suggestions?  
Stay safe and best regards  
Tonino

---

<div class="post-metadata">

**Author:** ![Truyenpt](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@Truyenpt](https://forum.generic-mapping-tools.org/u/Truyenpt)\
**Post date:** [November 22, 2021, 9:35pm UTC](https://forum.generic-mapping-tools.org/t/legend-from-a-input-file/2320/5 "2021-11-22T21:35:30Z")

</div>

Hi Tonino:

You can try this code:

S 0.25c - 0.5c - 2.0p, red 0.7c Mandeyapecua

Cheers!

PTT

---

<div class="post-metadata">

**Author:** ![tonino13](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/tonino13/32/1440_2.png) [@tonino13](https://forum.generic-mapping-tools.org/u/tonino13)\
**Post date:** [November 22, 2021, 9:45pm UTC](https://forum.generic-mapping-tools.org/t/legend-from-a-input-file/2320/6 "2021-11-22T21:45:18Z")

</div>

Dear @Truyenpt,  
Thank you, it worked.  
Stay safe and best regards,  
Tonino
