# Is there a toy dataset which is not linearly separable in 2d and linearly separable in 3D?

This figure is to illustrate a hyperplane

Is there a toy dataset could be used to draw this kind of figure with Python?

in other words, is there a dataset which is not linearly separable in 2d and linearly separable in 3D?

You could generate such a dataset using Python. A simple approach would be to generate a set of (x, y) coordinates, partition the set, then assign a distinct value for the z coordinate for each partition. An example with 100 points divided into 5 linearly separable partitions:

from mpl_toolkits.mplot3d import Axes3D

import matplotlib.pyplot as plt
import numpy as np

N = 100
K = 5                               # Partitions to split the N observations.
x = np.random.normal(0, 1, N)
y = np.random.normal(0, 1, N)
z = np.repeat(np.arange(K), N / K)  # One can simply shift the z-axis for
# partitions of the (x, y) coordinates
# Given this simple transformation, each
# partition is linearly separable.

# 2d plot
fig = plt.gcf()
plt.scatter(x, y, c=z)
plt.show()
fig.savefig('demo2d.png')

# 3d plot
fig = plt.figure()