What are the benefits?Qplot allows sharper, shorter and more concise syntax for declaring ggplot visualizations.
It is a great swiss army knife for plotting quick easy visualizations and is easily readable for those who haven’t used ggplot or R before.
qplot stands simply for quick plot is a shortcut designed to be familiar to ggplot2.
Let’s see how it works!Below I’ll show two ways of plotting the same visualization.
Using ggplot2 first, then using qplot.
Scatterplotggplot2ggplot(mpg) + geom_point(aes(displ, hwy, color = factor(cyl), shape = factor(cyl)))qplotqplot(displ, hwy, data = mpg, colour = factor(cyl), shape = factor(cyl))By using quick plot, we can shorten the syntax and make it more clear and concise.
The syntax becomes very similar to the seaborn library if you have programmed in python before.
Let’s take a look at a couple more examples!Bar ChartBar Chart using ggplotggplot2ggplot(data = diamonds) + geom_bar(aes(color, weight = carat, fill = color, alpha = 0.
5)) + scale_y_continuous("carat")qplotqplot(color, data = diamonds, geom = "bar", weight = carat, fill = color, alpha = 0.
5) + scale_y_continuous("carat")Scatter-plot & Line ChartScatter plot & line chartFirst we’ll take a small sample from the diamonds data set.
dsmall <- diamonds[sample(nrow(diamonds), 100),]ggplotggplot(dsmall, aes(carat, price)) + geom_point() + geom_smooth()qplotqplot(carat, price, data = dsmall, geom = c("point", "smooth"))BoxplotBoxplotggplotggplot(data = mpg) + geom_boxplot(mapping = aes(x = drv, y = hwy, color = manufacturer))qplotqplot(drv, hwy, data = mpg, color = manufacturer, geom = 'boxplot' )FinI hope this story taught you something new!.Both ggplot and qplot can be used to achieve the same effect.
But if you ever want decide to be indie, have a try of qplot for quick, dirty and simple data visualizations for Exploratory Data Analysis!As always, I welcome feedback and constructive criticism.
I can be reached on Twitter @Chippasaur.
If you liked this article, please do ????.and share it with your friends.
Remember, you can clap up to 50 times — it really makes a big difference for me.
.. More details