Created
July 31, 2018 15:46
-
-
Save kdorr/6adce3113f100e74f6822e537d870c20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ._convert import _convert | |
def convert(chart): | |
"""Convert an altair encoding to a Matplotlib figure | |
Parameters | |
---------- | |
chart | |
The Altair chart object generated by Altair | |
Returns | |
------- | |
fig | |
The Matplotlib figure | |
ax | |
The Matplotlib axes object | |
""" | |
fig, ax = plt.subplots() | |
if chart.mark is ('point', 'circle', 'square'): # scatter | |
mapping = _convert(chart) | |
ax.scatter(**mapping) | |
elif chart.mark == 'line': # line | |
data = _data.get_df() | |
if 'color' or 'stroke' in data: | |
for _, subset in data.groupby(color): | |
mapping = _convert(chart, subset) | |
ax.plot(**mapping) | |
return fig, ax |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment