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]:

Control Logo Size

Back to Top

You can adjust size of the logo by using .source_width and .source_height.

The example below increases the logo size to 3 times its original size.

In [7]:
x.clear()
logo2 = vcs.utils.Logo('./logo.png')
logo2.x = .05
logo2.y = .05
logo2.width = logo2.source_width * 3
logo2.height = logo2.source_height * 3
logo2.plot(x)
x.plot(d)
Out[7]:

This next example reduces the logo size to half of its original size.

In [8]:
x.clear()
logo2 = vcs.utils.Logo('./logo.png')
logo2.x = .05
logo2.y = .05
logo2.width = logo2.source_width * .5
logo2.height = logo2.source_height * .5
logo2.plot(x)
x.plot(d)
Out[8]:

Hide Unwanted Information Above the Plot

Back to Top

If your new logo conflicts with the information above the plot, you can hide unwanted items.

The result of the first code block below shows the new logo overlapping some of the existing text.

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

The following code hides the text above the plot.

In [10]:
my_template = vcs.createtemplate()
# Turn off unnecessary information to prevent overlap
my_template.blank(['title','dataname','crdate','crtime','mean','min','max',
           'units','zvalue','tvalue','xunits','yunits','xname','yname'])
x.clear()
logo2.plot(x)
x.plot(d,my_template)
Out[10]:

Please see the image below to identify the text elements you would like to hide.

controllable_parameters

Additional Template Controls

For more information on additional VCS template controls, please see the VCS Templates Notebook.

The CDAT software was developed by LLNL. This tutorial was written by Charles Doutriaux and Jiwoo Lee (Sep 2017) and updated by Holly Davis (Jan 2020). This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.

If you have questions about this notebook, please email our CDAT Support address, cdat-support@llnl.gov.