*! version 1.0.0 2026-07-18

Title

addlogo -- Stamp a logo onto a Stata graph

Syntax

addlogo [using imagefile],
logo(file)
saving(file)
[options]

Required
logo(file) logo image; a PNG with transparency is ideal

saving(file) output file; the format is taken from its extension

Placement
position(anchor) nw n ne w c e sw s se; default se

scale(#) logo width as a fraction of the graph width; default .12

pad(#) margin from the edge as a fraction of graph width; default .02

opacity(#) alpha multiplier 0-1; default 1

Source graph
width(#) export width in px for the current/named graph; default 2400

name(name) export a specific named graph in memory

Engine
engine(e) auto, python, or magick; default auto

pyexec(path) python interpreter that has Pillow

magickexec(path) path to the ImageMagick magick binary

replace overwrite saving() if it exists

Description

addlogo adds a logo to a Stata graph. Stata cannot place a raster image
inside the plot region, so addlogo exports the graph and then composites
the logo onto the exported image. The logo is sized relative to the graph
(see scale()), so it keeps the same proportions at whatever export
resolution you choose -- which keeps a set of figures looking consistent.

With no using, the current graph (or the one named in name()) is
exported first. A using ending in .gph is opened and rendered; any
other using is treated as an already-exported image. Output may be PNG,
TIF, JPG, or PDF; the format is taken from the saving() extension.

Getting started

The pattern is always the same -- draw a graph, then hand its name, your logo,
and an output file to addlogo:

(draw a graph) ..., name(mygraph, replace)

addlogo, logo(your_logo.png) saving(out.png) name(mygraph) replace

A complete, copy-paste example using Stata's own auto data (any PNG will
do for logo()):

. sysuse auto, clear

. scatter price mpg, name(g1, replace)

. addlogo, logo("logo.png") saving("price_mpg.png") name(g1) replace

That writes price_mpg.png with your logo in the bottom-right corner. From
there, move it with position(), resize it with scale(), and fade it
to a watermark with opacity(). See Examples for
more.

Options

Required

logo(file) is the logo to stamp. A PNG with a transparent
background gives the cleanest result; opacity() can fade it further.

saving(file) is the output file. Its extension sets the
format (.png, .tif, .jpg, .pdf). Combine with
replace to overwrite an existing file.

Placement

position(anchor) chooses one of nine anchors: nw n ne
(top), w c e (middle), sw s se (bottom). Long forms
(northwest, top-left, ...) are also accepted. The default is
se (bottom-right).

scale(#) sets the logo width as a fraction of the graph
width. scale(.12) (the default) makes the logo 12% as wide as the graph.

pad(#) is the margin between the logo and the graph edge, as a
fraction of the graph width (default .02).

opacity(#) multiplies the logo's alpha channel; 1 is
opaque, .85 a light watermark.

Source graph

width(#) is the pixel width at which the current or named
graph is exported before compositing (default 2400).

name(name) exports the named graph in memory instead of the
one currently displayed.

Engine

engine(e) selects the compositor: magick (ImageMagick),
python (Python + Pillow), or auto (the default: ImageMagick if its
binary is found, otherwise Python).

pyexec(path) and magickexec(path) give
the full path to the interpreter / binary. Alternatively set the globals
$ADDLOGO_PY and $ADDLOGO_MAGICK once in your profile.

Engines

addlogo needs one image compositor:

o ImageMagick -- install with brew install imagemagick
(macOS); it is used with no Python at all.

o Python + Pillow -- install with pip install Pillow; the
shipped helper addlogo_helper.py does the compositing.

On macOS, a Stata launched from the Dock has a minimal PATH that omits
/opt/homebrew/bin. Set the engine path once in your profile:

global ADDLOGO_MAGICK "/opt/homebrew/bin/magick"

global ADDLOGO_PY "/opt/homebrew/bin/python3"

Stored results

addlogo is rclass and stores in r():

Macros

r(file) the output file written

r(engine) the engine used (magick or python)

Examples

Brand the current graph, bottom-right:

. sysuse auto, clear

. twoway scatter price mpg, name(g1, replace)

. addlogo, logo("logo.png") saving("fig1.png") name(g1) replace

A light watermark, top-left:

. addlogo, logo("logo.png") saving("fig1.png") position(nw) scale(.18) opacity(.85) replace

Stamp a graph you saved earlier as .gph:

. addlogo using "fig.gph", logo("logo.png") saving("fig.png") replace

Re-brand an already-exported image:

. addlogo using "old.png", logo("logo.png") saving("old_branded.png") replace

Batch-brand every .gph in a folder:

. local files : dir "graphs" files "*.gph"

. foreach f of local files {

. local stem = substr("`f'", 1, strrpos("`f'", ".") - 1)

. addlogo using "graphs/`f'", logo("logo.png") saving("branded/`stem'.png") replace

. }

Remarks

For a true vector logo overlay in LaTeX / Beamer, export the graph as
.svg and inject an <image> tag, or overlay the logo at
\includegraphics time with a TikZ node. saving(fig.pdf) here gives
a raster-in-PDF, which embeds fine for most uses.

Author

Eric A. Booth, Sr Researcher, Texas 2036.
Email eric.a.booth@gmail.com.
MIT-licensed. A companion to googlechart, googlesheets, and
webapi.