%nbtoc
from pylab import *
import plotly
#py = plotly.plotly('me', 'key')
def to_plotly(ax=None):
'''
converts a matplotlib plot to a inline plotly plot.
'''
if ax is None:
ax = gca()
lines = []
for line in ax.get_lines():
lines.append({'x': line.get_xdata(),
'y': line.get_ydata(),
'name': line.get_label(),
})
layout = {'title':ax.get_title(),
'xaxis':{'title':ax.get_xlabel()},
'yaxis':{'title':ax.get_ylabel()}
}
filename = ax.get_title() if ax.get_title() != '' else 'Untitled'
print filename
close('all')
#return lines, layout
return py.iplot(lines,layout=layout, filename = filename)
import skrf as rf
# import some sample data for a Network
from skrf.data import ring_slot, ring_slot_meas
# note: using tex seems to eat up all non-text legend entries
#rcParams['text.usetex']=False
ring_slot.plot_s_db(title= 'Ring Slot Magnitude')
ring_slot.plot_s_db(title= 'Ring Slot Magnitude')
to_plotly()
Ring Slot Magnitude
ring_slot.plot_s_deg(title= 'Ring Slot Phase')
ring_slot.plot_s_deg(title= 'Ring Slot Phase')
to_plotly()
Ring Slot Phase
ring_slot.plot_s_complex()
ring_slot.plot_s_complex()
# not implmented:preserve aspect ratio
to_plotly()
Complex Plane
ring_slot.plot_s_smith()
ring_slot.plot_s_smith()
# not implmented: everything
to_plotly()
Untitled