<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <img style='float
Step1:  Connect to server
Step2:  <hr> Adding brushing
Several visualizations support brushing, including graphs, force networks, and scatter plots. Just set brush=True, then SHIFT-click and drag to select points. You should see them highlighted as you drag. We'll also turn off zooming for these examples, which can simplify our interactions with the plot.
Step3:  <hr> Getting selections
If working with a Lightning server (rather than the server-less mode), we can easily extract the points we've selected.
Step4:  Let's say I use the brush in the visualization above to select all points between 0 and 4. Below, I grab those points, and replot them -- note the new scale.
Step5:  I can use a different accessor, selected, to grab the indices of the selected points.
Step6:  Let's replot all points, but show the selected ones in a different color.
<ASSISTANT_TASK:>
Python Code:
from lightning import Lightning
from numpy import random, zeros
Explanation: <img style='float: left' src="http://lightning-viz.github.io/images/logo.png"> <br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Brushing in <a href='http://lightning-viz.github.io/'><font color='#9175f0'>Lightning</font></a>
<hr> Setup
End of explanation
lgn = Lightning(ipython=True, host='http://public.lightning-viz.org')
Explanation: Connect to server
End of explanation
x = random.randn(100)
y = random.randn(100)
lgn.scatter(x, y, brush=True, zoom=False)
Explanation: <hr> Adding brushing
Several visualizations support brushing, including graphs, force networks, and scatter plots. Just set brush=True, then SHIFT-click and drag to select points. You should see them highlighted as you drag. We'll also turn off zooming for these examples, which can simplify our interactions with the plot.
End of explanation
x = random.rand(100) * 10
y = random.rand(100) * 10
viz = lgn.scatter(x, y, brush=True, zoom=False)
viz
Explanation: <hr> Getting selections
If working with a Lightning server (rather than the server-less mode), we can easily extract the points we've selected.
End of explanation
sx, sy = viz.points()
lgn.scatter(sx, sy, zoom=False)
Explanation: Let's say I use the brush in the visualization above to select all points between 0 and 4. Below, I grab those points, and replot them -- note the new scale.
End of explanation
inds = viz.selected()
Explanation: I can use a different accessor, selected, to grab the indices of the selected points.
End of explanation
groups = zeros(100)
groups[inds] = 1
lgn.scatter(x, y, group=groups, zoom=False)
Explanation: Let's replot all points, but show the selected ones in a different color.
End of explanation
<END_TASK>