### First lets import all the different libraries we will be using # people say this is comparable to the tidyverseimport pandas as pd# similar to ggplotimport plotnine as pn# plots with js elements import plotly.express as px# syntax similar to matlabimport matplotlib.pyplot as matplt# plots that allow the user to import from the rendered markdownimport altair as altr# Import diamonds datasetdiamonds = sns.load_dataset('diamonds')diamonds.info()
This package is just like the ggplot2 package, one thing to note that instead of data = cars we see the ggplot(cars). In this case data = cars will give us an error
## Plotnine which is equivalent to ggplot(pn.ggplot(diamonds) + pn.aes(x='cut') + pn.geom_bar(size=20) + pn.coord_flip() + pn.ggtitle('Number of Diamonds by Cut'))
<Figure Size: (640 x 480)>
Plotly is pretty cool becuase she has interactive elements using java script
## Plotly px.histogram(diamonds, y ="cut", title="Number of Diamonds by Cut")
Altair also has some interactive elements like giving the viewer the option to save
My only issue is that I have not figure out how to make her a bigger size within a markdown document. Additionally altair can’t deal with data having more than 5000 rows
## Altair( altr.Chart( diamonds.sample(5000), title ="Number of Diamonds by Cut" ) .mark_bar() .encode( x ='count()', y = altr.Y('cut') ))