Skip to content

How to use mpl-altair #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions _posts/2018-08-21-how-to-use-mpl-altair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
layout: post
title: "How to Use mpl-altair"
date: 2018-08-21 3:45:00 -0500
author: "Kimberly Orr"
categories: about
tags: "intro about"
excerpt_separator: <!--read more-->
---

**Process**
1. create a chart using Altair
2. call mplaltair's `convert` function
3. show the figure or add to it using Matplotlib

```python
import pandas as pd
df = pd.DataFrame({'x': [1, 2, 3, 4], 'y': [1, 10, 1000, 10000]})

# Step 1
import altair as alt
import matplotlib.pyplot as plt
import mplaltair
chart = alt.Chart(df).mark_point().encode(
alt.X('x'), alt.Y('y', alt.Scale(type='log'))
)

# Step 2
fig, ax = mplaltair.convert(chart)

# Step 3
plt.show()
```