examples/jupyter/integrations/matplotlib.ipynb
import modin.pandas as pd
import pandas
import numpy as np
import matplotlib.pyplot as plt
# Create a visualization with Modin df
# Example modified from https://matplotlib.org/3.1.1/gallery/lines_bars_and_markers/xcorr_acorr_demo.html#sphx-glr-gallery-lines-bars-and-markers-xcorr-acorr-demo-py
# Fixing random state for reproducibility
np.random.seed(19680801)
x = pd.DataFrame(np.random.randn(100, 1),columns=["Col_1"])
y = pd.DataFrame(np.random.randn(100, 1),columns=["Col_1"])
fig, [ax1, ax2] = plt.subplots(2, 1, sharex=True)
ax1.xcorr(x["Col_1"], y["Col_1"], usevlines=True, maxlags=50, normed=True, lw=2)
ax1.grid(True)
ax2.acorr(x["Col_1"], usevlines=True, normed=True, maxlags=50, lw=2)
ax2.grid(True)
plt.show()
# Create a visualization with pandas df
# Example modified from https://matplotlib.org/3.1.1/gallery/lines_bars_and_markers/xcorr_acorr_demo.html#sphx-glr-gallery-lines-bars-and-markers-xcorr-acorr-demo-py
# Fixing random state for reproducibility
np.random.seed(19680801)
x = pandas.DataFrame(np.random.randn(100, 1),columns=["Col_1"])
y = pandas.DataFrame(np.random.randn(100, 1),columns=["Col_1"])
fig, [ax1, ax2] = plt.subplots(2, 1, sharex=True)
ax1.xcorr(x["Col_1"], y["Col_1"], usevlines=True, maxlags=50, normed=True, lw=2)
ax1.grid(True)
ax2.acorr(x["Col_1"], usevlines=True, normed=True, maxlags=50, lw=2)
ax2.grid(True)
plt.show()
# Create a visualization with Modin df
# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]
modin_df = pd.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})
plt.figure(figsize=(9, 3))
plt.subplot(131)
plt.bar(modin_df['names'], modin_df['values'])
plt.subplot(132)
#plt.scatter(df['names'], df['values'])
#plt.subplot(133)
plt.plot(modin_df['names'], modin_df['values'])
plt.suptitle('Categorical Plotting')
plt.show()
# Create a visualization with pandas df
# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]
pandas_df = pandas.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})
plt.figure(figsize=(9, 3))
plt.subplot(131)
plt.bar(pandas_df['names'], pandas_df['values'])
plt.subplot(132)
plt.plot(pandas_df['names'], pandas_df['values'])
plt.suptitle('Categorical Plotting')
plt.show()
# Create a visualization with Modin df
# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]
modin_df = pd.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})
plt.figure(figsize=(9, 3))
plt.subplot(131)
plt.barh(modin_df['names'], modin_df['values'])
plt.subplot(132)
#plt.scatter(df['names'], df['values'])
#plt.subplot(133)
plt.plot(modin_df['names'], modin_df['values'])
plt.suptitle('Categorical Plotting')
plt.show()
# Create a visualization with pandas df
# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]
pandas_df = pandas.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})
plt.figure(figsize=(9, 3))
plt.subplot(131)
plt.barh(pandas_df['names'], pandas_df['values'])
plt.subplot(132)
plt.plot(pandas_df['names'], pandas_df['values'])
plt.suptitle('Categorical Plotting')
plt.show()
plt.figure(figsize=(9, 3))
plt.subplot(131)
plt.hlines(pandas_df['values'], 1, 3)
plt.suptitle('Categorical Plotting')
plt.show()
# Create a visualization with Modin df
# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]
modin_df = pd.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})
plt.figure(figsize=(9, 3))
plt.subplot(131)
plt.bar(modin_df['names'], modin_df['values'])
plt.subplot(132)
#plt.scatter(df['names'], df['values'])
#plt.subplot(133)
plt.plot(modin_df['names'], modin_df['values'])
plt.suptitle('Categorical Plotting')
plt.show()
# Create a visualization with pandas df
# Example modified from https://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py
names = ['group_a', 'group_b', 'group_c']
values = [1, 10, 100]
pandas_df = pandas.DataFrame({'names':['group_a', 'group_b', 'group_c'],'values':[1, 10, 100]})
plt.figure(figsize=(9, 3))
plt.subplot(131)
plt.bar(pandas_df['names'], pandas_df['values'])
plt.subplot(132)
#plt.scatter(df['names'], df['values'])
#plt.subplot(133)
plt.plot(pandas_df['names'], pandas_df['values'])
plt.suptitle('Categorical Plotting')
plt.show()