Cookies help us display personalized product recommendations and ensure you have great shopping experience.

By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
SmartData CollectiveSmartData Collective
  • Analytics
    AnalyticsShow More
    image fx (67)
    Improving LinkedIn Ad Strategies with Data Analytics
    9 Min Read
    big data and remote work
    Data Helps Speech-Language Pathologists Deliver Better Results
    6 Min Read
    data driven insights
    How Data-Driven Insights Are Addressing Gaps in Patient Communication and Equity
    8 Min Read
    pexels pavel danilyuk 8112119
    Data Analytics Is Revolutionizing Medical Credentialing
    8 Min Read
    data and seo
    Maximize SEO Success with Powerful Data Analytics Insights
    8 Min Read
  • Big Data
  • BI
  • Exclusive
  • IT
  • Marketing
  • Software
Search
© 2008-25 SmartData Collective. All Rights Reserved.
Reading: ggplot2 and the grammar of graphics
Share
Notification
Font ResizerAa
SmartData CollectiveSmartData Collective
Font ResizerAa
Search
  • About
  • Help
  • Privacy
Follow US
© 2008-23 SmartData Collective. All Rights Reserved.
SmartData Collective > Big Data > Data Visualization > ggplot2 and the grammar of graphics
Data Visualization

ggplot2 and the grammar of graphics

DavidMSmith
DavidMSmith
4 Min Read
SHARE

I really enjoyed Hadley Wickham’s talk for the Bay Area UseR group last week. I’ve really been getting into ggplot2 lately, but it was Hadley’s example of plotting housing sales data for the San Francisco area really made it click for me. When you first start using ggplot2, the syntax can seem a little, well, arcane: rather than using separate commands to build up your plot as with traditional R graphics, you string elements together with the ‘+‘ operator. The example Hadley showed, plotting time-series data, laying on a line, and then paneling the data by city, really made sense of the “grammar of graphics” concept for me.  

It looks like the folks at Biogeeks have had a similar epiphany recently:

Say you want to make 12 dose-response plots of various compounds tested in various cell lines. With basic R this would require writing a for-loop and fidling around a lot with axis and plot labeling and the par()-function to make them fit on one page. With basic R you would have be extremely careful to make the code general and reusable for next time when you have different compounds and different cell lines. Enter ggplot2 and the grammar of graphics. ggplot2 is a package for …

More Read

Image
The Diary of a Construction Manager in Love with His Business Intelligence Solution
8 Ways That College Sports Teams Can Use Data to Prove Value to Sponsors
Will Big Data Mark the End of the Market Research Industry?
Workforce Planning and HR Analytics
Want to Fully Leverage Data? Change the Way You Operate

I really enjoyed Hadley Wickham’s talk for the Bay Area UseR group last week. I’ve really been getting into ggplot2 lately, but it was Hadley’s example of plotting housing sales data for the San Francisco area really made it click for me. When you first start using ggplot2, the syntax can seem a little, well, arcane: rather than using separate commands to build up your plot as with traditional R graphics, you string elements together with the ‘+‘ operator. The example Hadley showed, plotting time-series data, laying on a line, and then paneling the data by city, really made sense of the “grammar of graphics” concept for me.  

It looks like the folks at Biogeeks have had a similar epiphany recently:

Say you want to make 12 dose-response plots of various compounds tested in various cell lines. With basic R this would require writing a for-loop and fidling around a lot with axis and plot labeling and the par()-function to make them fit on one page. With basic R you would have be extremely careful to make the code general and reusable for next time when you have different compounds and different cell lines. Enter ggplot2 and the grammar of graphics. ggplot2 is a package for implementing the grammar of graphics, which allows you to write extremely succinct and natural languages like code that produces stunning visualizations.

Here’s 6 lines of code in ggplot2, and the graph it creates:

p = qplot(Concentration, Percent.of.control, 
data=screening_data,
geom=c("point", "smooth"), colour=Response.type) +
scale_x_log10() +
facet_grid(Compound ~ Cell.line) +
coord_cartesian(ylim=c(-10, 110))
print(p)

Ggplot2_ex1

So how does the grammar of graphics help, here? I liked the way the Biogeeks summed it up: “If you compare the code and the plot you will realize that the code contains about the words that you would use if you were told to briefly describe the plot using English.” Indeed!

Biogeeks: Power plotting with ggplot2

Link to original post

TAGGED:ggplot2
Share This Article
Facebook Pinterest LinkedIn
Share

Follow us on Facebook

Latest News

image fx (2)
Monitoring Data Without Turning into Big Brother
Big Data Exclusive
image fx (71)
The Power of AI for Personalization in Email
Artificial Intelligence Exclusive Marketing
image fx (67)
Improving LinkedIn Ad Strategies with Data Analytics
Analytics Big Data Exclusive Software
big data and remote work
Data Helps Speech-Language Pathologists Deliver Better Results
Analytics Big Data Exclusive

Stay Connected

1.2kFollowersLike
33.7kFollowersFollow
222FollowersPin

You Might also Like

10 R Packages Every Data Scientist Should Know About

1 Min Read

Interactive stock visualizations with R

3 Min Read

Lattice and ggplot graphics, side by side

3 Min Read

SmartData Collective is one of the largest & trusted community covering technical content about Big Data, BI, Cloud, Analytics, Artificial Intelligence, IoT & more.

AI chatbots
AI Chatbots Can Help Retailers Convert Live Broadcast Viewers into Sales!
Chatbots
AI and chatbots
Chatbots and SEO: How Can Chatbots Improve Your SEO Ranking?
Artificial Intelligence Chatbots Exclusive

Quick Link

  • About
  • Contact
  • Privacy
Follow US
© 2008-25 SmartData Collective. All Rights Reserved.
Go to mobile version
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?