# How to add Legends to distinguish between graphs plotted from different gas files using Garfield++?

**URL:** <https://root-forum.cern.ch/t/how-to-add-legends-to-distinguish-between-graphs-plotted-from-different-gas-files-using-garfield/53882>\
**Category:** Garfield++\
**Created:** [March 5, 2023, 12:05pm UTC](https://root-forum.cern.ch/t/how-to-add-legends-to-distinguish-between-graphs-plotted-from-different-gas-files-using-garfield/53882 "2023-03-05T12:05:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbdelrahmanMekawy](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/7bcc69/32.png) [@AbdelrahmanMekawy](https://root-forum.cern.ch/u/AbdelrahmanMekawy)\
**Post date:** [March 5, 2023, 12:05pm UTC](https://root-forum.cern.ch/t/how-to-add-legends-to-distinguish-between-graphs-plotted-from-different-gas-files-using-garfield/53882/1 "2023-03-05T12:05:45Z")

</div>

hello, how can I add a legend on a graph to distinguish between graphs plotted (on the same canvas) from different gas files using Garfield++?

like plotting the electron drift velocity in two different gases, for example

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [March 5, 2023, 12:39pm UTC](https://root-forum.cern.ch/t/how-to-add-legends-to-distinguish-between-graphs-plotted-from-different-gas-files-using-garfield/53882/2 "2023-03-05T12:39:18Z")

</div>

You can use the method `SetLabels` of the class `ViewMedium` to set the labels of each graph explicitly.

---

<div class="post-metadata">

**Author:** ![AbdelrahmanMekawy](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/7bcc69/32.png) [@AbdelrahmanMekawy](https://root-forum.cern.ch/u/AbdelrahmanMekawy)\
**Post date:** [March 5, 2023, 1:50pm UTC](https://root-forum.cern.ch/t/how-to-add-legends-to-distinguish-between-graphs-plotted-from-different-gas-files-using-garfield/53882/3 "2023-03-05T13:50:58Z")

</div>

thanks a lot, I declared string vectors then used them in SetLabels and it workd!!

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [March 19, 2023, 1:51pm UTC](https://root-forum.cern.ch/t/how-to-add-legends-to-distinguish-between-graphs-plotted-from-different-gas-files-using-garfield/53882/4 "2023-03-19T13:51:03Z")

</div>

Closed on March 19, 2023, 1:51pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
