Skip to content

Instantly share code, notes, and snippets.

@palnabarun
Last active Aug 8, 2018
Embed
What would you like to do?
from matplotlib import pyplot as plt
from mplaltair._convert import _convert
from mplaltair._data import _normalize_spec, _locate_channel_field
def _handle_area(chart, ax):
raise NotImplementedError
def _handle_bar(chart, ax):
raise NotImplementedError
def _handle_circle(chart, ax):
'''Nearly the same as _handle_point but with hollow scatter points
FIXME:
'''
encodings = _convert(chart)
ax.scatter(**encodings)
def _handle_geoshape(chart, ax):
raise NotImplementedError
def _handle_line(chart, ax):
chart_spec = _normalize_spec(chart)
data = chart_spec['data']
if 'color' in chart_spec['encodings']:
field = _locate_channel_field(chart, 'color')
for val, subset in data.groupby(field):
ax.plot(data=subset, x=_locate_channel_field(chart, 'x'), y=_locate_channel_field(chart, 'y'), label=val)
plt.legend(title=field)
def _handle_point(chart, ax):
encodings = _convert(chart)
ax.scatter(**encodings)
def _handle_rect(chart, ax):
raise NotImplementedError
def _handle_square(chart, ax):
raise NotImplementedError
def _handle_text(chart, ax):
raise NotImplementedError
def _handle_tick(chart, ax):
raise NotImplementedError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment