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.)
Let's prepare a sample VCS plot to test the logo control. The VCS canvas is designated as x
in this notebook.
# 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)
import cdms2, vcs
f = cdms2.open('clt.nc')
d = f('clt')
x = vcs.init()
x.plot(d)
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.
x.drawlogooff()
x.clear()
x.plot(d)
You can bring back the default CDAT logo by using .drawlogoon()
.
x.drawlogoon()
x.clear()
x.plot(d)
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.
x.clear()
logo2 = vcs.utils.Logo('./logo.png')
logo2.plot(x)
x.plot(d)
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.)
x.clear()
logo2 = vcs.utils.Logo('./logo.png')
logo2.x = .05
logo2.y = .05
logo2.plot(x)
x.plot(d)