You can use a function assigner:
from dolfin import *
import numpy as np
import matplotlib.pyplot as plt
mesh = UnitSquareMesh(10, 10)
V = VectorFunctionSpace(mesh, "CG", 1)
w = Function(V)
x = V.tabulate_dof_coordinates()
w_array = w.vector().get_local()
V0 = V.sub(0).collapse()
x0 = V0.tabulate_dof_coordinates()
w0 = Function(V0)
w0_array = w0.vector().get_local()
for i in range(x0.shape[0]):
if x0[i, 0] == 0 and x0[i, 1] <= 0.5:
w0_array[i] = 1.0
w0.vector().set_local(w0_array)
fa = FunctionAssigner(V.sub(0), V0)
fa.assign(w.sub(0), w0)
p = plot(w)
plt.colorbar(p)
plt.savefig("vector-plot.png")