megashigger
megashigger

Reputation: 9053

How do you make ggplot plots of numpy arrays?

I know how to use ggplot for data frames, but is there a good way to make plots from numpy arrays directly? Or do I have to convert?

Upvotes: 4

Views: 1488

Answers (1)

ali_m
ali_m

Reputation: 74242

If you just want to plot things in a "ggplot-like style", you can use the matplotlib.style package:

import numpy as np
from matplotlib import pyplot as plt
from matplotlib import style

# use ggplot style sheet
style.use('ggplot')

plt.plot(np.random.randn(10))

enter image description here

Of course (as cel pointed out), with matplotlib it's still up to you to make sure your plots actually follow the conventions set out in Grammar of Graphics.

Upvotes: 3

Related Questions