In [2]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#from matplotlib.ticker import MultipleLocator, FormatStrFormatter
import matplotlib as mpl
import sys
%matplotlib inline
# %config InlineBackend.figure_format = 'svg'   #uses high resolution vectorized output
# plt.rcParams['figure.figsize'] = (9, 7)

In [3]:
print('Python: ', sys.version)
print('OS: ',sys.platform)
print('pandas version: ', pd.__version__)
print('matplotlib version: ', mpl.__version__)


Python:  3.6.3 |Anaconda, Inc.| (default, Oct 27 2017, 12:14:30) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
OS:  darwin
pandas version:  0.21.0
matplotlib version:  2.1.0

In [4]:
df = pd.read_csv('stress_strain_data.csv', sep=',', header=None, skiprows=0)
df.columns = ['strain', 'stress']
df.head()


Out[4]:
strain stress
0 0.000000 0.000
1 0.000605 43.821
2 0.001211 74.356
3 0.001816 104.930
4 0.002421 137.510

Plot with pandas


In [5]:
df.plot()


Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0x10deac518>

Plot with matplotlib


In [6]:
strain = df['strain']
stress = df['stress']
plt.plot(strain,stress)
plt.xlabel('strain')
plt.ylabel('stress')
plt.title('matplotlib')
plt.show()


Plot with altair


In [7]:
import altair as alt

# Uncomment/run this line to enable Altair in JupyterLab/nteract:
# alt.enable_mime_rendering()
print("Altair Version: ", alt.__version__)
df.head()


Altair Version:  1.2.1
Out[7]:
strain stress
0 0.000000 0.000
1 0.000605 43.821
2 0.001211 74.356
3 0.001816 104.930
4 0.002421 137.510

In [8]:
alt.Chart(df).mark_line().encode(
    x='strain',
    y='stress'
)



In [9]:
import holoviews as hv
hv.extension('bokeh')
import bokeh
print('holovies version: ', hv.__version__)
print('bokeh version, ', bokeh.__version__)


holovies version:  1.9.2
bokeh version,  0.12.13

In [10]:
hv.archive.auto()
scatter = hv.Curve(df, 'strain', 'stress')
scatter


Automatic capture is now enabled. [2017-12-21 12:16:43]
Out[10]:

In [11]:
hv.archive.export()


Export name: 'altair_and_holoviews'
Directory    '/Users/FamilyComputer/Documents/staticsite/content/code/tensiletest'

If no output appears, please check holoviews.archive.last_export_status()

In [24]:
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.embed import file_html

In [ ]: