# Controlling size in Lightning

## Setup

In [1]:
import os
from lightning import Lightning

from numpy import random


## Connect to server¶

In [2]:
lgn = Lightning(ipython=True, host='http://public.lightning-viz.org')

Lightning initialized
Connected to server at http://public.lightning-viz.org


## Sizing individual plots

The Lightning client let's you easily control plot size by specifying the width in pixels. Let's try a few sizes for the same plot.

In [3]:
x = random.rand(100)
y = random.rand(100)
mat = random.rand(100,100)
mat[mat<0.99] = 0

In [4]:
lgn.graph(x, y, mat, width=400)

Out[4]:
In [5]:
lgn.graph(x, y, mat, width=800)

Out[5]:

## Global size

Especially when working in the notebook, it can be useful to specify a size globally. We've predefined four sizes: small, medium, large, and full. Generally, full will be the largest, but full is also adaptive and will match the size of the enclosing div, whereas the others correspond to fixed pixel widths of 400, 600, and 800. The default for notebooks is medium, but for some plot types and use cases you may prefer others.

In [6]:
series = random.randn(5,50)

In [7]:
lgn.set_size('small')
lgn.line(series)

Out[7]:
In [8]:
lgn.set_size('medium')
lgn.line(series)

Out[8]:
In [9]:
lgn.set_size('large')
lgn.line(series)

Out[9]:
In [10]:
lgn.set_size('full')
lgn.line(series)

Out[10]: