Logo Control on the VCS Canvas

If desired, the default CDAT logo, located at the bottom right of a plot, can be turned off.

An additional logo can also be displayed.

To download this Jupyter Notebook, right click on the link and choose "Download Linked File As..." or "Save Link as...". Remember where you saved the downloaded file, which should have an .ipynb extension. (You'll need to launch the Jupyter notebook or JupyterLab instance from the location where you store the notebook file.)

Prepare a Sample Plot

Back to Top

Let's prepare a sample VCS plot to test the logo control. The VCS canvas is designated as x in this notebook.

In [1]:
# Sample data
import requests
r = requests.get("https://cdat.llnl.gov/cdat/sample_data/clt.nc",stream=True)
with open("clt.nc","wb") as f:
    for chunk in r.iter_content(chunk_size=1024):
        if chunk:  # filter local_filename keep-alive new chunks
            f.write(chunk)
In [2]:
import cdms2, vcs
f = cdms2.open('clt.nc')
d = f('clt')
x = vcs.init()
x.plot(d)
Out[2]:

Turn OFF the Default CDAT Logo

Back to Top

To hide the default CDAT logo located at the bottom right use .drawlogooff().

Note: if running the code in the cell below does not remove the logo, run the cell a second time.

In [3]:
x.drawlogooff()
x.clear()
x.plot(d)
Out[3]:

Turn ON the Default CDAT Logo

Back to Top

You can bring back the default CDAT logo by using .drawlogoon().

In [4]:
x.drawlogoon()
x.clear()
x.plot(d)
Out[4]:

Insert an Additional Logo

Back to Top

Place the image file for the logo you want to add to the plot in the same directory as this notebook. In this example, we use an LLNL logo file called "logo.png" which can be downloaded from this notebook's GitHub repository: https://github.com/CDAT/Jupyter-notebooks/tree/master/vcs/Logo_Control.

The vcs.utils.Logo() method allows you to plot the additional logo.

The default location of the new logo is at the top right.

In [5]:
x.clear()
logo2 = vcs.utils.Logo('./logo.png')
logo2.plot(x)
x.plot(d)
Out[5]:

Control Logo Location

Back to Top

You can adjust the position of the logo by using the .x and .y methods.

The value of .x and .y should be between 0 and 1 since they represent a ratio of the relative position on the canvas. (logo2.x = 0.5 would be 50% of the way across the canvas in the x direction.)

In [6]:
x.clear()
logo2 = vcs.utils.Logo('./logo.png')
logo2.x = .05
logo2.y = .05
logo2.plot(x)
x.plot(d)
Out[6]: