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
    sales and data analytics
    How Data Analytics Improves Lead Management and Sales Results
    9 Min Read
    data analytics and truck accident claims
    How Data Analytics Reduces Truck Accidents and Speeds Up Claims
    7 Min Read
    predictive analytics for interior designers
    Interior Designers Boost Profits with Predictive Analytics
    8 Min Read
    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
  • 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

What Is Your Dashboard Telling You?
Open Data App for the Paris Métro
What Data Visualization Reveals About Your Own LinkedIn Network
Top 3 Ways FP&A Analytics Can Get Your Financial House in Order
The Dark Matter of Data

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

sales and data analytics
How Data Analytics Improves Lead Management and Sales Results
Analytics Big Data Exclusive
ai in marketing
How AI and Smart Platforms Improve Email Marketing
Artificial Intelligence Exclusive Marketing
AI Document Verification for Legal Firms: Importance & Top Tools
AI Document Verification for Legal Firms: Importance & Top Tools
Artificial Intelligence Exclusive
AI supply chain
AI Tools Are Strengthening Global Supply Chains
Artificial Intelligence Exclusive

Stay Connected

1.2kFollowersLike
33.7kFollowersFollow
222FollowersPin

You Might also Like

Interactive stock visualizations with R

3 Min Read

Lattice and ggplot graphics, side by side

3 Min Read

10 R Packages Every Data Scientist Should Know About

1 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 is improving the safety of cars
From Bolts to Bots: How AI Is Fortifying the Automotive Industry
Artificial Intelligence
AI chatbots
AI Chatbots Can Help Retailers Convert Live Broadcast Viewers into Sales!
Chatbots

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?