In [1]:
# Imports
import numpy as np
import scipy as sp
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
In [3]:
# Load R magic
%load_ext rmagic
In [11]:
# Make data to plot in python
x = np.random.uniform(0, 1000, size=1000)
y = np.random.normal(1000, size=1000)
In [42]:
# Plot using matplotlib
plt.scatter(x=x, y=y, color='k')
plt.xlabel('X', fontsize=14)
plt.ylabel('Y', fontsize=14)
plt.grid()
Here is a simple plot using R. First we push our x and y arrays over to R and then plot them.
In [14]:
%Rpush x y
%R plot(x, y)
A little more complicated plot can be done using the R cell magic command %%R
. Here everything in the cell is called with R.
In [29]:
%%R -i x,y
library(ggplot2)
dat = data.frame(x=x, y=y)
ggplot(dat, aes(x=x, y=y)) + geom_point()
See this IPython notebook for more information about R magic.
In [ ]: