Mathplot Circle

import matplotlib.pyplot as plt 
 
figure, axes = plt.subplots() 
cc = plt.Circle(( 0.5 , 0.5 ), 0.4 ) 
 
axes.set_aspect( 1 ) 
axes.add_artist( cc ) 
plt.title( 'Colored Circle' )

# plt.axis('off')

plt.show()

BQplot Line

from bqplot import *
from IPython.display import display

x_data = range(10)
y_data = [i ** 2 for i in x_data]

x_sc = LinearScale()
y_sc = LinearScale()

ax_x = Axis(label='Test X', scale=x_sc, tick_format='0.0f')
ax_y = Axis(label='Test Y', scale=y_sc,
            orientation='vertical', tick_format='0.2f')

line = Lines(x=x_data,
             y=y_data,
             scales={'x': x_sc, 'y': y_sc},
             colors=['red', 'yellow'])

fig = Figure(axes=[ax_x, ax_y], marks=[line])

display(fig)

BQplot Line

bqplot is an interactive plotting library. Attributes of plots can be updated in place without recreating the whole figure and marks. Let's look at idiomatic ways of updating plots in bqplot

import numpy as np
import ipywidgets as widgets
from ipywidgets import interact, Layout, IntSlider, FloatSlider

# Jupyter Specifics
#
from IPython.display import HTML
from ipywidgets.widgets import interact, IntSlider, FloatSlider, Dropdown, Layout
import bqplot.pyplot as plt
x = np.linspace(-10, 10, 100)
y = np.sin(x)

fig = plt.figure()
line = plt.plot(x=x, y=y)

fig

BQplot Circle

def points_arround_circle(number=100, center=(0,0), radius=1):
    theta = np.linspace(0, 2 * np.pi - (2 * np.pi / number), number)
    x = radius * np.cos(theta)
    y = radius * np.sin(theta)

    return (x, y)
def get_lines_from_points(x, y, factor, animated=None):
    limit = len(x)
    if animated is not None:
        for i in range(limit):
            x_range = (x[i], x[int(i * factor) % limit])
            y_range = (y[i], y[int(i * factor) % limit])
            yield mlines.Line2D(x_range, y_range)
    else:
        for i in range(limit):
            start = (x[i], y[i])
            index = int((i * factor) % limit)
            end = (x[index], y[index])          
            yield end, start
def plot_circle_points(x, y, ax, labels=None):
    # ax.annotate("Points: {}".format(len(x)), (0.8, 0.9))
    ax.plot(x, y, "-ko", markevery=1)
    if not labels is None:
        for i, (x, y) in enumerate(zip(x, y)):
            ax.annotate(i, (x, y))
def plot_lines(x, y, factor, ax, color=None):
    # ax.annotate("Factor: {}".format(factor), (0.8, 1))
    lines = list(get_lines_from_points(x, y, factor))
    if color is None:
        line_segments = LineCollection(lines)
    else:
        line_segments = LineCollection(lines, colors=colorsys.hsv_to_rgb(color, 1.0, 0.8))
            
    ax.add_collection(line_segments)
import numpy as np

from IPython.display import HTML
from ipywidgets.widgets import interact, IntSlider, FloatSlider, Dropdown, Layout

from bqplot import *
from IPython.display import display

Factor = 10
Points = 10

x_sc = LinearScale()
y_sc = LinearScale()

ax_x = Axis(label='Test X', scale=x_sc, tick_format='0.0f')
ax_y = Axis(label='Test Y', scale=y_sc,
            orientation='vertical', tick_format='0.2f')

x_data, y_data = points_arround_circle(number=Points)
# plot_circle_points(x_data, y_data, ax_y)


# plot_lines(x_data, y_data, Factor, ax_x)

line = Lines(x=x_data,
             y=y_data,
             scales={'x': x_sc, 'y': y_sc},
             colors=['red', 'yellow'])

fig = Figure(axes=[ax_x, ax_y], marks=[line])

# figsize: width|height recalculated from inches to pixels
fig.layout.width = '500px'
fig.layout.height = '500px'

# Removing axes and background gridlines
ax_x.grid_lines = "none"
ax_y.grid_lines = "none"

ax_x.color = "white"
ax_y.color = "white"

ax_x.num_ticks = 0
ax_y.num_ticks = 0

display(fig)