In markdown, you can use markup. You can do fun things like change the font color or size.
# Boring stuff
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import mpld3
from mpld3 import plugins, utils
%matplotlib inline
plt.xkcd()
labels = ['$t_1$','$t_{forever}$']
fig = plt.figure()
ax = fig.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
plt.xticks([3,99],labels)
plt.yticks([0])
plt.tick_params(
axis='both',
which='both',
bottom='off',
top='off',
left='off',
right='off',
labelbottom='on')
plt.xlabel('time spent thinking about funny plots')
plt.ylabel('how funny plot actually is')
ax.set_ylim([-1, 10])
data = np.zeros(100)
plt.plot(data)
plt.show()
class LinkedView(plugins.PluginBase):
"""A simple plugin showing how multiple axes can be linked"""
JAVASCRIPT = """
mpld3.register_plugin("linkedview", LinkedViewPlugin);
LinkedViewPlugin.prototype = Object.create(mpld3.Plugin.prototype);
LinkedViewPlugin.prototype.constructor = LinkedViewPlugin;
LinkedViewPlugin.prototype.requiredProps = ["idpts", "idline", "data"];
LinkedViewPlugin.prototype.defaultProps = {}
function LinkedViewPlugin(fig, props){
mpld3.Plugin.call(this, fig, props);
};
LinkedViewPlugin.prototype.draw = function(){
var pts = mpld3.get_element(this.props.idpts);
var line = mpld3.get_element(this.props.idline);
var data = this.props.data;
function mouseover(d, i){
line.data = data[i];
line.elements().transition()
.attr("d", line.datafunc(line.data))
.style("stroke", this.style.fill);
}
pts.elements().on("mouseover", mouseover);
};
"""
def __init__(self, points, line, linedata):
if isinstance(points, mpl.lines.Line2D):
suffix = "pts"
else:
suffix = None
self.dict_ = {"type": "linkedview",
"idpts": utils.get_id(points, suffix),
"idline": utils.get_id(line),
"data": linedata}
fig, ax = plt.subplots(2)
# scatter periods and amplitudes
np.random.seed(0)
P = np.linspace(0, 4, 5)
A = np.ones(5)
x = np.linspace(0, 10, 100)
data = np.array([[x, Ai * (x)]
for (Ai, Pi) in zip(A, P)])
points = ax[1].scatter(P, A, c=P + A,
s=200, alpha=0.5)
ax[1].set_xlabel('Color')
plt.yticks([0])
xlabels = ['purple','blue','green','yellow','red']
plt.xticks([0,1,2,3,4],xlabels)
# create the line object
lines = ax[0].plot(x, 0 * x, '-w', lw=3, alpha=0.5)
ax[0].set_ylim(0, 10)
ax[0].set_title("What color do you want your line to be?")
# transpose line data and add plugin
linedata = data.transpose(0, 2, 1).tolist()
plugins.connect(fig, LinkedView(points, lines[0], linedata))
mpld3.display()